All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
@ 2019-01-31 15:30 Michal Simek
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 1/7] dm: core: Add of_alias_get_highest_id() Michal Simek
                   ` (8 more replies)
  0 siblings, 9 replies; 40+ messages in thread
From: Michal Simek @ 2019-01-31 15:30 UTC (permalink / raw)
  To: u-boot

U-Boot with I2C_DM enabled is not capable to list i2c busses connected
to i2c mux. For getting this work there is a need to find out highest
alias ID and use this uniq number for new buses connected to I2C mux.
This series is making this happen.

There is only one missing piece which is that also i2c controllers which
are not listed in DT are not using this feature.

Removing setting up aliases from i2c mux code and unifying it in the
same code ensures that numbering schema is proper if no alias is
specified.

ZynqMP> i2c bus
Bus 0:	i2c at ff020000
   20: gpio at 20, offset len 1, flags 0
   21: gpio at 21, offset len 1, flags 0
   75: i2c-mux at 75, offset len 1, flags 0
Bus 1:	i2c at ff020000->i2c-mux at 75->i2c at 0
Bus 2:	i2c at ff020000->i2c-mux at 75->i2c at 1
Bus 3:	i2c at ff020000->i2c-mux at 75->i2c at 2
Bus 4:	i2c at ff030000  (active 4)
   74: i2c-mux at 74, offset len 1, flags 0
   75: i2c-mux at 75, offset len 1, flags 0
Bus 5:	i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
   54: eeprom at 54, offset len 1, flags 0
Bus 6:	i2c at ff030000->i2c-mux at 74->i2c at 1
Bus 7:	i2c at ff030000->i2c-mux at 74->i2c at 2
Bus 8:	i2c at ff030000->i2c-mux at 74->i2c at 3
Bus 9:	i2c at ff030000->i2c-mux at 74->i2c at 4
Bus 10:	i2c at ff030000->i2c-mux at 75->i2c at 0
Bus 11:	i2c at ff030000->i2c-mux at 75->i2c at 1
Bus 12:	i2c at ff030000->i2c-mux at 75->i2c at 2
Bus 13:	i2c at ff030000->i2c-mux at 75->i2c at 3
Bus 14:	i2c at ff030000->i2c-mux at 75->i2c at 4
Bus 15:	i2c at ff030000->i2c-mux at 75->i2c at 5
Bus 16:	i2c at ff030000->i2c-mux at 75->i2c at 6
Bus 17:	i2c at ff030000->i2c-mux at 75->i2c at 7

Thanks,
Michal

Changes in v2:
- Update kernel-doc binding
- Return -1 in case of error. -1 means that the next free alias is 0.
- New patch
- New patch
- Use dev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus name

Michal Simek (7):
  dm: core: Add of_alias_get_highest_id()
  fdt: Introduce fdtdec_get_alias_highest_id()
  dm: core: Introduce dev_read_alias_highest_id()
  dm: core: Add tests for dev_read_alias_highest_id()
  i2c: dm: Record maximum id of devices before probing devices
  i2c: Fill req_seq in i2c_post_bind()
  i2c: mux: Generate longer i2c mux name

 drivers/core/of_access.c           | 18 ++++++++++++++
 drivers/core/read.c                |  8 ++++++
 drivers/i2c/i2c-uclass.c           | 50 +++++++++++++++++++++++++++++++++++---
 drivers/i2c/muxes/i2c-mux-uclass.c | 29 +++++++++++++++++++---
 include/dm/of_access.h             | 10 ++++++++
 include/dm/read.h                  | 16 ++++++++++++
 include/fdtdec.h                   | 13 ++++++++++
 lib/fdtdec.c                       | 33 +++++++++++++++++++++++++
 test/dm/test-fdt.c                 | 23 ++++++++++++++++++
 9 files changed, 194 insertions(+), 6 deletions(-)

-- 
1.9.1

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

* [U-Boot] [PATCH v2 1/7] dm: core: Add of_alias_get_highest_id()
  2019-01-31 15:30 [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Michal Simek
@ 2019-01-31 15:30 ` Michal Simek
  2019-02-07  6:46   ` Heiko Schocher
  2019-02-11 15:50   ` Heiko Schocher
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 2/7] fdt: Introduce fdtdec_get_alias_highest_id() Michal Simek
                   ` (7 subsequent siblings)
  8 siblings, 2 replies; 40+ messages in thread
From: Michal Simek @ 2019-01-31 15:30 UTC (permalink / raw)
  To: u-boot

The same functionality was added to Linux for i2c bus registration with this
commit message:

"
of: base: add function to get highest id of an alias stem

I2C supports adding adapters using either a dynamic or fixed id. The
latter is provided by aliases in the DT case. To prevent id collisions
of those two types, install this function which gives us the highest
fixed id, so we can then let the dynamically created ones come after
this highest number.

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
"

Add it also to U-Boot for DM I2C support.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2:
- Update kernel-doc binding
- Return -1 in case of error. -1 means that the next free alias is 0.

 drivers/core/of_access.c | 18 ++++++++++++++++++
 include/dm/of_access.h   | 10 ++++++++++
 2 files changed, 28 insertions(+)

diff --git a/drivers/core/of_access.c b/drivers/core/of_access.c
index 14c020a687b7..945b81448cce 100644
--- a/drivers/core/of_access.c
+++ b/drivers/core/of_access.c
@@ -812,6 +812,24 @@ int of_alias_get_id(const struct device_node *np, const char *stem)
 	return id;
 }
 
+int of_alias_get_highest_id(const char *stem)
+{
+	struct alias_prop *app;
+	int id = -1;
+
+	mutex_lock(&of_mutex);
+	list_for_each_entry(app, &aliases_lookup, link) {
+		if (strcmp(app->stem, stem) != 0)
+			continue;
+
+		if (app->id > id)
+			id = app->id;
+	}
+	mutex_unlock(&of_mutex);
+
+	return id;
+}
+
 struct device_node *of_get_stdout(void)
 {
 	return of_stdout;
diff --git a/include/dm/of_access.h b/include/dm/of_access.h
index 5ed1a0cdb427..13fedb7cf5e6 100644
--- a/include/dm/of_access.h
+++ b/include/dm/of_access.h
@@ -425,6 +425,16 @@ int of_alias_scan(void);
 int of_alias_get_id(const struct device_node *np, const char *stem);
 
 /**
+ * of_alias_get_highest_id - Get highest alias id for the given stem
+ * @stem:	Alias stem to be examined
+ *
+ * The function travels the lookup table to get the highest alias id for the
+ * given alias stem.
+ * @return alias ID, if found, else -1
+ */
+int of_alias_get_highest_id(const char *stem);
+
+/**
  * of_get_stdout() - Get node to use for stdout
  *
  * @return node referred to by stdout-path alias, or NULL if none
-- 
1.9.1

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

* [U-Boot] [PATCH v2 2/7] fdt: Introduce fdtdec_get_alias_highest_id()
  2019-01-31 15:30 [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Michal Simek
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 1/7] dm: core: Add of_alias_get_highest_id() Michal Simek
@ 2019-01-31 15:30 ` Michal Simek
  2019-02-07  6:47   ` Heiko Schocher
                     ` (2 more replies)
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 3/7] dm: core: Introduce dev_read_alias_highest_id() Michal Simek
                   ` (6 subsequent siblings)
  8 siblings, 3 replies; 40+ messages in thread
From: Michal Simek @ 2019-01-31 15:30 UTC (permalink / raw)
  To: u-boot

Find out the highest alias ID used for certain subsystem.
This call will be used for alocating IDs for i2c buses which are not
described in DT.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2: None

 include/fdtdec.h | 13 +++++++++++++
 lib/fdtdec.c     | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index f1bcbf837ffb..c2dd87ede226 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -626,6 +626,19 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int node,
 			 int *seqp);
 
 /**
+ * Get the highest alias number for susbystem.
+ *
+ * It parses all aliases and find out highest recorded alias for subsystem.
+ * Aliases are of the form <base><num> where <num> is the sequence number.
+ *
+ * @param blob		Device tree blob (if NULL, then error is returned)
+ * @param base		Base name for alias susbystem (before the number)
+ *
+ * @return 0 highest alias ID, -1 if not found
+ */
+int fdtdec_get_alias_highest_id(const void *blob, const char *base);
+
+/**
  * Get a property from the /chosen node
  *
  * @param blob		Device tree blob (if NULL, then NULL is returned)
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index 18663ce6bdac..55811975ef54 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -549,6 +549,39 @@ int fdtdec_get_alias_seq(const void *blob, const char *base, int offset,
 	return -ENOENT;
 }
 
+int fdtdec_get_alias_highest_id(const void *blob, const char *base)
+{
+	int base_len = strlen(base);
+	int prop_offset;
+	int aliases;
+	int max = -1;
+
+	debug("Looking for highest alias id for '%s'\n", base);
+
+	aliases = fdt_path_offset(blob, "/aliases");
+	for (prop_offset = fdt_first_property_offset(blob, aliases);
+	     prop_offset > 0;
+	     prop_offset = fdt_next_property_offset(blob, prop_offset)) {
+		const char *prop;
+		const char *name;
+		int len, val;
+
+		prop = fdt_getprop_by_offset(blob, prop_offset, &name, &len);
+		debug("   - %s, %s\n", name, prop);
+		if (*prop != '/' || prop[len - 1] ||
+		    strncmp(name, base, base_len))
+			continue;
+
+		val = trailing_strtol(name);
+		if (val > max) {
+			debug("Found seq %d\n", val);
+			max = val;
+		}
+	}
+
+	return max;
+}
+
 const char *fdtdec_get_chosen_prop(const void *blob, const char *name)
 {
 	int chosen_node;
-- 
1.9.1

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

* [U-Boot] [PATCH v2 3/7] dm: core: Introduce dev_read_alias_highest_id()
  2019-01-31 15:30 [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Michal Simek
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 1/7] dm: core: Add of_alias_get_highest_id() Michal Simek
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 2/7] fdt: Introduce fdtdec_get_alias_highest_id() Michal Simek
@ 2019-01-31 15:30 ` Michal Simek
  2019-02-07  6:48   ` Heiko Schocher
                     ` (2 more replies)
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 4/7] dm: core: Add tests for dev_read_alias_highest_id() Michal Simek
                   ` (5 subsequent siblings)
  8 siblings, 3 replies; 40+ messages in thread
From: Michal Simek @ 2019-01-31 15:30 UTC (permalink / raw)
  To: u-boot

It is wrapper for calling of_alias_get_highest_id() when live tree is
enabled and fdtdec_get_alias_highest_id() if not.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2:
- New patch

 drivers/core/read.c |  8 ++++++++
 include/dm/read.h   | 16 ++++++++++++++++
 2 files changed, 24 insertions(+)

diff --git a/drivers/core/read.c b/drivers/core/read.c
index 3c46b3674ed6..6bda077a34b9 100644
--- a/drivers/core/read.c
+++ b/drivers/core/read.c
@@ -264,3 +264,11 @@ u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr)
 {
 	return ofnode_translate_address(dev_ofnode(dev), in_addr);
 }
+
+int dev_read_alias_highest_id(const char *stem)
+{
+	if (of_live_active())
+		return of_alias_get_highest_id(stem);
+
+	return fdtdec_get_alias_highest_id(gd->fdt_blob, stem);
+}
diff --git a/include/dm/read.h b/include/dm/read.h
index 389e30e7fb44..60b727cbd821 100644
--- a/include/dm/read.h
+++ b/include/dm/read.h
@@ -510,6 +510,17 @@ int dev_read_resource_byname(struct udevice *dev, const char *name,
  * @return the translated address; OF_BAD_ADDR on error
  */
 u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_addr);
+
+/**
+ * dev_read_alias_highest_id - Get highest alias id for the given stem
+ * @stem:	Alias stem to be examined
+ *
+ * The function travels the lookup table to get the highest alias id for the
+ * given alias stem.
+ * @return alias ID, if found, else -1
+ */
+int dev_read_alias_highest_id(const char *stem);
+
 #else /* CONFIG_DM_DEV_READ_INLINE is enabled */
 
 static inline int dev_read_u32(struct udevice *dev,
@@ -740,6 +751,11 @@ static inline u64 dev_translate_address(struct udevice *dev, const fdt32_t *in_a
 	return ofnode_translate_address(dev_ofnode(dev), in_addr);
 }
 
+static inline int dev_read_alias_highest_id(const char *stem)
+{
+	return fdtdec_get_alias_highest_id(gd->fdt_blob, stem);
+}
+
 #endif /* CONFIG_DM_DEV_READ_INLINE */
 
 /**
-- 
1.9.1

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

* [U-Boot] [PATCH v2 4/7] dm: core: Add tests for dev_read_alias_highest_id()
  2019-01-31 15:30 [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Michal Simek
                   ` (2 preceding siblings ...)
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 3/7] dm: core: Introduce dev_read_alias_highest_id() Michal Simek
@ 2019-01-31 15:31 ` Michal Simek
  2019-02-07  6:49   ` Heiko Schocher
                     ` (2 more replies)
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 5/7] i2c: dm: Record maximum id of devices before probing devices Michal Simek
                   ` (4 subsequent siblings)
  8 siblings, 3 replies; 40+ messages in thread
From: Michal Simek @ 2019-01-31 15:31 UTC (permalink / raw)
  To: u-boot

It is checking the highest alias ID for eth, gpio, pci, i2c and error
code on non existing alias.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2:
- New patch

 test/dm/test-fdt.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/test/dm/test-fdt.c b/test/dm/test-fdt.c
index 984b80c02c81..be16c99e170e 100644
--- a/test/dm/test-fdt.c
+++ b/test/dm/test-fdt.c
@@ -219,6 +219,29 @@ static int dm_test_fdt(struct unit_test_state *uts)
 }
 DM_TEST(dm_test_fdt, 0);
 
+static int dm_test_alias_highest_id(struct unit_test_state *uts)
+{
+	int ret;
+
+	ret = dev_read_alias_highest_id("eth");
+	ut_asserteq(5, ret);
+
+	ret = dev_read_alias_highest_id("gpio");
+	ut_asserteq(2, ret);
+
+	ret = dev_read_alias_highest_id("pci");
+	ut_asserteq(2, ret);
+
+	ret = dev_read_alias_highest_id("i2c");
+	ut_asserteq(0, ret);
+
+	ret = dev_read_alias_highest_id("deadbeef");
+	ut_asserteq(-1, ret);
+
+	return 0;
+}
+DM_TEST(dm_test_alias_highest_id, 0);
+
 static int dm_test_fdt_pre_reloc(struct unit_test_state *uts)
 {
 	struct uclass *uc;
-- 
1.9.1

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

* [U-Boot] [PATCH v2 5/7] i2c: dm: Record maximum id of devices before probing devices
  2019-01-31 15:30 [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Michal Simek
                   ` (3 preceding siblings ...)
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 4/7] dm: core: Add tests for dev_read_alias_highest_id() Michal Simek
@ 2019-01-31 15:31 ` Michal Simek
  2019-02-07  6:49   ` Heiko Schocher
  2019-02-11 15:54   ` Heiko Schocher
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 6/7] i2c: Fill req_seq in i2c_post_bind() Michal Simek
                   ` (3 subsequent siblings)
  8 siblings, 2 replies; 40+ messages in thread
From: Michal Simek @ 2019-01-31 15:31 UTC (permalink / raw)
  To: u-boot

There is a need to find out the first free i2c ID which can be used for
i2s buses (including i2c buses connected to i2c mux). Do it early in
init and share this variable with other i2c classes for uniq bus
identification.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2:
- Use dev_read_alias_highest_id()
- Use uclass private data

 drivers/i2c/i2c-uclass.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index 975318e5f254..b26602f3de95 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -619,6 +619,26 @@ static int i2c_child_post_bind(struct udevice *dev)
 #endif
 }
 
+struct i2c_priv {
+	int max_id;
+};
+
+int i2c_uclass_init(struct uclass *class)
+{
+	struct i2c_priv *priv = class->priv;
+
+	/* Just for sure */
+	if (!priv)
+		return -ENOMEM;
+
+	/* Get the last allocated alias. */
+	priv->max_id = dev_read_alias_highest_id("i2c");
+
+	debug("%s: highest alias id is %d\n", __func__, priv->max_id);
+
+	return 0;
+}
+
 UCLASS_DRIVER(i2c) = {
 	.id		= UCLASS_I2C,
 	.name		= "i2c",
@@ -626,6 +646,8 @@ UCLASS_DRIVER(i2c) = {
 #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
 	.post_bind	= dm_scan_fdt_dev,
 #endif
+	.init		= i2c_uclass_init,
+	.priv_auto_alloc_size = sizeof(struct i2c_priv),
 	.post_probe	= i2c_post_probe,
 	.per_device_auto_alloc_size = sizeof(struct dm_i2c_bus),
 	.per_child_platdata_auto_alloc_size = sizeof(struct dm_i2c_chip),
-- 
1.9.1

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

* [U-Boot] [PATCH v2 6/7] i2c: Fill req_seq in i2c_post_bind()
  2019-01-31 15:30 [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Michal Simek
                   ` (4 preceding siblings ...)
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 5/7] i2c: dm: Record maximum id of devices before probing devices Michal Simek
@ 2019-01-31 15:31 ` Michal Simek
  2019-02-07  6:52   ` Heiko Schocher
  2019-02-11 15:54   ` Heiko Schocher
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name Michal Simek
                   ` (2 subsequent siblings)
  8 siblings, 2 replies; 40+ messages in thread
From: Michal Simek @ 2019-01-31 15:31 UTC (permalink / raw)
  To: u-boot

For i2c controllers which are missing alias in DT there is no req_seq
setup. This function is setting up proper ID based on highest found
alias ID.

On zcu102 this is the behavior when patch is applied.
ZynqMP> i2c bus
Bus 0:	i2c at ff020000
   20: gpio at 20, offset len 1, flags 0
   21: gpio at 21, offset len 1, flags 0
   75: i2c-mux at 75, offset len 1, flags 0
Bus 2:	i2c at 0
Bus 3:	i2c at 1
Bus 4:	i2c at 2
Bus 1:	i2c at ff030000  (active 1)
   74: i2c-mux at 74, offset len 1, flags 0
   75: i2c-mux at 75, offset len 1, flags 0
Bus 5:	i2c at 0  (active 5)
   54: eeprom at 54, offset len 1, flags 0
Bus 6:	i2c at 1
Bus 7:	i2c at 2
Bus 8:	i2c at 3
Bus 9:	i2c at 4
Bus 10:	i2c at 0
Bus 11:	i2c at 1
Bus 12:	i2c at 2
Bus 13:	i2c at 3
Bus 14:	i2c at 4
Bus 15:	i2c at 5
Bus 16:	i2c at 6
Bus 17:	i2c at 7

Before this patch applied (controllers have -1 ID)
ZynqMP> i2c bus
Bus 0:	i2c at ff020000
   20: gpio at 20, offset len 1, flags 0
   21: gpio at 21, offset len 1, flags 0
   75: i2c-mux at 75, offset len 1, flags 0
Bus -1:	i2c at 0
Bus -1:	i2c at 1
Bus -1:	i2c at 2
Bus 1:	i2c at ff030000  (active 1)
   74: i2c-mux at 74, offset len 1, flags 0
   75: i2c-mux at 75, offset len 1, flags 0
Bus -1:	i2c at 0  (active 0)
   54: eeprom at 54, offset len 1, flags 0
Bus -1:	i2c at 1
Bus -1:	i2c at 2
Bus -1:	i2c at 3
Bus -1:	i2c at 4
Bus -1:	i2c at 0
Bus -1:	i2c at 1
Bus -1:	i2c at 2
Bus -1:	i2c at 3
Bus -1:	i2c at 4
Bus -1:	i2c at 5
Bus -1:	i2c at 6
Bus -1:	i2c at 7

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2:
- Use private uclass data

 drivers/i2c/i2c-uclass.c | 28 +++++++++++++++++++++++++---
 1 file changed, 25 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index b26602f3de95..6f3fca2d2326 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -623,6 +623,30 @@ struct i2c_priv {
 	int max_id;
 };
 
+static int i2c_post_bind(struct udevice *dev)
+{
+	struct uclass *class = dev->uclass;
+	struct i2c_priv *priv = class->priv;
+	int ret = 0;
+
+	/* Just for sure */
+	if (!priv)
+		return -ENOMEM;
+
+	debug("%s: %s, req_seq=%d\n", __func__, dev->name, dev->req_seq);
+
+	/* if there is no alias ID, use the first free */
+	if (dev->req_seq == -1)
+		dev->req_seq = ++priv->max_id;
+
+	debug("%s: %s, new req_seq=%d\n", __func__, dev->name, dev->req_seq);
+
+#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
+	ret = dm_scan_fdt_dev(dev);
+#endif
+	return ret;
+}
+
 int i2c_uclass_init(struct uclass *class)
 {
 	struct i2c_priv *priv = class->priv;
@@ -643,9 +667,7 @@ UCLASS_DRIVER(i2c) = {
 	.id		= UCLASS_I2C,
 	.name		= "i2c",
 	.flags		= DM_UC_FLAG_SEQ_ALIAS,
-#if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)
-	.post_bind	= dm_scan_fdt_dev,
-#endif
+	.post_bind	= i2c_post_bind,
 	.init		= i2c_uclass_init,
 	.priv_auto_alloc_size = sizeof(struct i2c_priv),
 	.post_probe	= i2c_post_probe,
-- 
1.9.1

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

* [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name
  2019-01-31 15:30 [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Michal Simek
                   ` (5 preceding siblings ...)
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 6/7] i2c: Fill req_seq in i2c_post_bind() Michal Simek
@ 2019-01-31 15:31 ` Michal Simek
  2019-02-02 15:00   ` Simon Glass
                     ` (2 more replies)
  2019-02-02 14:10 ` [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Simon Glass
  2019-02-08  9:57 ` Heiko Schocher
  8 siblings, 3 replies; 40+ messages in thread
From: Michal Simek @ 2019-01-31 15:31 UTC (permalink / raw)
  To: u-boot

For !DM case busses are listed as
ZynqMP> i2c bus
Bus 0:	zynq_0
Bus 1:	zynq_0->PCA9544A at 0x75:0
Bus 2:	zynq_0->PCA9544A at 0x75:1
Bus 3:	zynq_0->PCA9544A at 0x75:2
Bus 4:	zynq_1
Bus 5:	zynq_1->PCA9548 at 0x74:0
Bus 6:	zynq_1->PCA9548 at 0x74:1
Bus 7:	zynq_1->PCA9548 at 0x74:2
Bus 8:	zynq_1->PCA9548 at 0x74:3
Bus 9:	zynq_1->PCA9548 at 0x74:4
Bus 10:	zynq_1->PCA9548 at 0x75:0
Bus 11:	zynq_1->PCA9548 at 0x75:1
Bus 12:	zynq_1->PCA9548 at 0x75:2
Bus 13:	zynq_1->PCA9548 at 0x75:3
Bus 14:	zynq_1->PCA9548 at 0x75:4
Bus 15:	zynq_1->PCA9548 at 0x75:5
Bus 16:	zynq_1->PCA9548 at 0x75:6
Bus 17:	zynq_1->PCA9548 at 0x75:7

where is exactly describing i2c bus topology.
By moving to DM case i2c mux buses are using names from DT and because
i2c-muxes describing sub busses with the same names like i2c at 0, etc it
is hard to identify which bus is where.
Linux is adding topology information to i2c-mux busses to identify them
better.
This patch is doing the same and composing bus name with topology
information.

When patch is applied with topology information on zcu102-revA.
ZynqMP> i2c bus
Bus 0:	i2c at ff020000
   20: gpio at 20, offset len 1, flags 0
   21: gpio at 21, offset len 1, flags 0
   75: i2c-mux at 75, offset len 1, flags 0
Bus 2:	i2c at ff020000->i2c-mux at 75->i2c at 0
Bus 3:	i2c at ff020000->i2c-mux at 75->i2c at 1
Bus 4:	i2c at ff020000->i2c-mux at 75->i2c at 2
Bus 1:	i2c at ff030000  (active 1)
   74: i2c-mux at 74, offset len 1, flags 0
   75: i2c-mux at 75, offset len 1, flags 0
Bus 5:	i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
   54: eeprom at 54, offset len 1, flags 0
Bus 6:	i2c at ff030000->i2c-mux at 74->i2c at 1
Bus 7:	i2c at ff030000->i2c-mux at 74->i2c at 2
Bus 8:	i2c at ff030000->i2c-mux at 74->i2c at 3
Bus 9:	i2c at ff030000->i2c-mux at 74->i2c at 4
Bus 10:	i2c at ff030000->i2c-mux at 75->i2c at 0
Bus 11:	i2c at ff030000->i2c-mux at 75->i2c at 1
Bus 12:	i2c at ff030000->i2c-mux at 75->i2c at 2
Bus 13:	i2c at ff030000->i2c-mux at 75->i2c at 3
Bus 14:	i2c at ff030000->i2c-mux at 75->i2c at 4
Bus 15:	i2c at ff030000->i2c-mux at 75->i2c at 5
Bus 16:	i2c at ff030000->i2c-mux at 75->i2c at 6
Bus 17:	i2c at ff030000->i2c-mux at 75->i2c at 7

Behavior before the patch is applied.
ZynqMP> i2c bus
Bus 0:	i2c at ff020000
   20: gpio at 20, offset len 1, flags 0
   21: gpio at 21, offset len 1, flags 0
   75: i2c-mux at 75, offset len 1, flags 0
Bus 2:	i2c at 0
Bus 3:	i2c at 1
Bus 4:	i2c at 2
Bus 1:	i2c at ff030000  (active 1)
   74: i2c-mux at 74, offset len 1, flags 0
   75: i2c-mux at 75, offset len 1, flags 0
Bus 5:	i2c at 0  (active 5)
   54: eeprom at 54, offset len 1, flags 0
Bus 6:	i2c at 1
Bus 7:	i2c at 2
Bus 8:	i2c at 3
Bus 9:	i2c at 4
Bus 10:	i2c at 0
Bus 11:	i2c at 1
Bus 12:	i2c at 2
Bus 13:	i2c at 3
Bus 14:	i2c at 4
Bus 15:	i2c at 5
Bus 16:	i2c at 6
Bus 17:	i2c at 7

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2:
- Fix headers
- Change patch description to focus only on bus name

 drivers/i2c/muxes/i2c-mux-uclass.c | 29 ++++++++++++++++++++++++++---
 1 file changed, 26 insertions(+), 3 deletions(-)

diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c
index a680ee176253..8b1149997a19 100644
--- a/drivers/i2c/muxes/i2c-mux-uclass.c
+++ b/drivers/i2c/muxes/i2c-mux-uclass.c
@@ -59,11 +59,34 @@ static int i2c_mux_post_bind(struct udevice *mux)
 	dev_for_each_subnode(node, mux) {
 		struct udevice *dev;
 		const char *name;
+		const char *arrow = "->";
+		char *full_name;
+		int parent_name_len, arrow_len, mux_name_len, name_len;
 
 		name = ofnode_get_name(node);
-		ret = device_bind_driver_to_node(mux, "i2c_mux_bus_drv", name,
-						 node, &dev);
-		debug("   - bind ret=%d, %s\n", ret, dev ? dev->name : NULL);
+
+		/* Calculate lenghts of strings */
+		parent_name_len = strlen(mux->parent->name);
+		arrow_len = strlen(arrow);
+		mux_name_len = strlen(mux->name);
+		name_len = strlen(name);
+
+		full_name = calloc(1, parent_name_len + arrow_len +
+				   mux_name_len + arrow_len + name_len + 1);
+		if (!full_name)
+			return -ENOMEM;
+
+		/* Compose bus name */
+		strcat(full_name, mux->parent->name);
+		strcat(full_name, arrow);
+		strcat(full_name, mux->name);
+		strcat(full_name, arrow);
+		strcat(full_name, name);
+
+		ret = device_bind_driver_to_node(mux, "i2c_mux_bus_drv",
+						 full_name, node, &dev);
+		debug("   - bind ret=%d, %s, req_seq %d\n", ret,
+		      dev ? dev->name : NULL, dev->req_seq);
 		if (ret)
 			return ret;
 	}
-- 
1.9.1

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-01-31 15:30 [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Michal Simek
                   ` (6 preceding siblings ...)
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name Michal Simek
@ 2019-02-02 14:10 ` Simon Glass
  2019-02-05  7:57   ` Michal Simek
  2019-02-08  9:57 ` Heiko Schocher
  8 siblings, 1 reply; 40+ messages in thread
From: Simon Glass @ 2019-02-02 14:10 UTC (permalink / raw)
  To: u-boot

Hi Michal,

On Thu, 31 Jan 2019 at 08:31, Michal Simek <michal.simek@xilinx.com> wrote:
>
> U-Boot with I2C_DM enabled is not capable to list i2c busses connected
> to i2c mux. For getting this work there is a need to find out highest
> alias ID and use this uniq number for new buses connected to I2C mux.
> This series is making this happen.
>
> There is only one missing piece which is that also i2c controllers which
> are not listed in DT are not using this feature.
>
> Removing setting up aliases from i2c mux code and unifying it in the
> same code ensures that numbering schema is proper if no alias is
> specified.
>
> ZynqMP> i2c bus
> Bus 0:  i2c at ff020000
>    20: gpio at 20, offset len 1, flags 0
>    21: gpio at 21, offset len 1, flags 0
>    75: i2c-mux at 75, offset len 1, flags 0
> Bus 1:  i2c at ff020000->i2c-mux at 75->i2c at 0
> Bus 2:  i2c at ff020000->i2c-mux at 75->i2c at 1
> Bus 3:  i2c at ff020000->i2c-mux at 75->i2c at 2
> Bus 4:  i2c at ff030000  (active 4)
>    74: i2c-mux at 74, offset len 1, flags 0
>    75: i2c-mux at 75, offset len 1, flags 0
> Bus 5:  i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>    54: eeprom at 54, offset len 1, flags 0
> Bus 6:  i2c at ff030000->i2c-mux at 74->i2c at 1
> Bus 7:  i2c at ff030000->i2c-mux at 74->i2c at 2
> Bus 8:  i2c at ff030000->i2c-mux at 74->i2c at 3
> Bus 9:  i2c at ff030000->i2c-mux at 74->i2c at 4
> Bus 10: i2c at ff030000->i2c-mux at 75->i2c at 0
> Bus 11: i2c at ff030000->i2c-mux at 75->i2c at 1
> Bus 12: i2c at ff030000->i2c-mux at 75->i2c at 2
> Bus 13: i2c at ff030000->i2c-mux at 75->i2c at 3
> Bus 14: i2c at ff030000->i2c-mux at 75->i2c at 4
> Bus 15: i2c at ff030000->i2c-mux at 75->i2c at 5
> Bus 16: i2c at ff030000->i2c-mux at 75->i2c at 6
> Bus 17: i2c at ff030000->i2c-mux at 75->i2c at 7
>
> Thanks,
> Michal
>
> Changes in v2:
> - Update kernel-doc binding
> - Return -1 in case of error. -1 means that the next free alias is 0.
> - New patch
> - New patch
> - Use dev_read_alias_highest_id()
> - Use uclass private data
> - Use private uclass data
> - Fix headers
> - Change patch description to focus only on bus name

I don't have strong objections to this series, but I'd still like to
try a bit harder on the existing req_seq/seq stuff.

I don't think we necessarily need to set the 'seq' before probe,
although I suppose we could.

But is there anything to stop us moving some of the logic which sets
seq to setting req_seq? We could check the aliases and then set
req_seq during bind(), perhaps?

This would be better for code size since it would help all subsystems.

Regards,
Simon

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

* [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name Michal Simek
@ 2019-02-02 15:00   ` Simon Glass
  2019-02-07  6:55   ` Heiko Schocher
  2019-02-11 15:55   ` Heiko Schocher
  2 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2019-02-02 15:00 UTC (permalink / raw)
  To: u-boot

On Thu, 31 Jan 2019 at 08:31, Michal Simek <michal.simek@xilinx.com> wrote:
>
> For !DM case busses are listed as
> ZynqMP> i2c bus
> Bus 0:  zynq_0
> Bus 1:  zynq_0->PCA9544A at 0x75:0
> Bus 2:  zynq_0->PCA9544A at 0x75:1
> Bus 3:  zynq_0->PCA9544A at 0x75:2
> Bus 4:  zynq_1
> Bus 5:  zynq_1->PCA9548 at 0x74:0
> Bus 6:  zynq_1->PCA9548 at 0x74:1
> Bus 7:  zynq_1->PCA9548 at 0x74:2
> Bus 8:  zynq_1->PCA9548 at 0x74:3
> Bus 9:  zynq_1->PCA9548 at 0x74:4
> Bus 10: zynq_1->PCA9548 at 0x75:0
> Bus 11: zynq_1->PCA9548 at 0x75:1
> Bus 12: zynq_1->PCA9548 at 0x75:2
> Bus 13: zynq_1->PCA9548 at 0x75:3
> Bus 14: zynq_1->PCA9548 at 0x75:4
> Bus 15: zynq_1->PCA9548 at 0x75:5
> Bus 16: zynq_1->PCA9548 at 0x75:6
> Bus 17: zynq_1->PCA9548 at 0x75:7
>
> where is exactly describing i2c bus topology.
> By moving to DM case i2c mux buses are using names from DT and because
> i2c-muxes describing sub busses with the same names like i2c at 0, etc it
> is hard to identify which bus is where.
> Linux is adding topology information to i2c-mux busses to identify them
> better.
> This patch is doing the same and composing bus name with topology
> information.
>
> When patch is applied with topology information on zcu102-revA.
> ZynqMP> i2c bus
> Bus 0:  i2c at ff020000
>    20: gpio at 20, offset len 1, flags 0
>    21: gpio at 21, offset len 1, flags 0
>    75: i2c-mux at 75, offset len 1, flags 0
> Bus 2:  i2c at ff020000->i2c-mux at 75->i2c at 0
> Bus 3:  i2c at ff020000->i2c-mux at 75->i2c at 1
> Bus 4:  i2c at ff020000->i2c-mux at 75->i2c at 2
> Bus 1:  i2c at ff030000  (active 1)
>    74: i2c-mux at 74, offset len 1, flags 0
>    75: i2c-mux at 75, offset len 1, flags 0
> Bus 5:  i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>    54: eeprom at 54, offset len 1, flags 0
> Bus 6:  i2c at ff030000->i2c-mux at 74->i2c at 1
> Bus 7:  i2c at ff030000->i2c-mux at 74->i2c at 2
> Bus 8:  i2c at ff030000->i2c-mux at 74->i2c at 3
> Bus 9:  i2c at ff030000->i2c-mux at 74->i2c at 4
> Bus 10: i2c at ff030000->i2c-mux at 75->i2c at 0
> Bus 11: i2c at ff030000->i2c-mux at 75->i2c at 1
> Bus 12: i2c at ff030000->i2c-mux at 75->i2c at 2
> Bus 13: i2c at ff030000->i2c-mux at 75->i2c at 3
> Bus 14: i2c at ff030000->i2c-mux at 75->i2c at 4
> Bus 15: i2c at ff030000->i2c-mux at 75->i2c at 5
> Bus 16: i2c at ff030000->i2c-mux at 75->i2c at 6
> Bus 17: i2c at ff030000->i2c-mux at 75->i2c at 7
>
> Behavior before the patch is applied.
> ZynqMP> i2c bus
> Bus 0:  i2c at ff020000
>    20: gpio at 20, offset len 1, flags 0
>    21: gpio at 21, offset len 1, flags 0
>    75: i2c-mux at 75, offset len 1, flags 0
> Bus 2:  i2c at 0
> Bus 3:  i2c at 1
> Bus 4:  i2c at 2
> Bus 1:  i2c at ff030000  (active 1)
>    74: i2c-mux at 74, offset len 1, flags 0
>    75: i2c-mux at 75, offset len 1, flags 0
> Bus 5:  i2c at 0  (active 5)
>    54: eeprom at 54, offset len 1, flags 0
> Bus 6:  i2c at 1
> Bus 7:  i2c at 2
> Bus 8:  i2c at 3
> Bus 9:  i2c at 4
> Bus 10: i2c at 0
> Bus 11: i2c at 1
> Bus 12: i2c at 2
> Bus 13: i2c at 3
> Bus 14: i2c at 4
> Bus 15: i2c at 5
> Bus 16: i2c at 6
> Bus 17: i2c at 7
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> Changes in v2:
> - Fix headers
> - Change patch description to focus only on bus name
>
>  drivers/i2c/muxes/i2c-mux-uclass.c | 29 ++++++++++++++++++++++++++---
>  1 file changed, 26 insertions(+), 3 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-02-02 14:10 ` [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Simon Glass
@ 2019-02-05  7:57   ` Michal Simek
  2019-02-05  8:20     ` Heiko Schocher
  2019-02-08  4:11     ` Simon Glass
  0 siblings, 2 replies; 40+ messages in thread
From: Michal Simek @ 2019-02-05  7:57 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 02. 02. 19 15:10, Simon Glass wrote:
> Hi Michal,
> 
> On Thu, 31 Jan 2019 at 08:31, Michal Simek <michal.simek@xilinx.com> wrote:
>>
>> U-Boot with I2C_DM enabled is not capable to list i2c busses connected
>> to i2c mux. For getting this work there is a need to find out highest
>> alias ID and use this uniq number for new buses connected to I2C mux.
>> This series is making this happen.
>>
>> There is only one missing piece which is that also i2c controllers which
>> are not listed in DT are not using this feature.
>>
>> Removing setting up aliases from i2c mux code and unifying it in the
>> same code ensures that numbering schema is proper if no alias is
>> specified.
>>
>> ZynqMP> i2c bus
>> Bus 0:  i2c at ff020000
>>    20: gpio at 20, offset len 1, flags 0
>>    21: gpio at 21, offset len 1, flags 0
>>    75: i2c-mux at 75, offset len 1, flags 0
>> Bus 1:  i2c at ff020000->i2c-mux at 75->i2c at 0
>> Bus 2:  i2c at ff020000->i2c-mux at 75->i2c at 1
>> Bus 3:  i2c at ff020000->i2c-mux at 75->i2c at 2
>> Bus 4:  i2c at ff030000  (active 4)
>>    74: i2c-mux at 74, offset len 1, flags 0
>>    75: i2c-mux at 75, offset len 1, flags 0
>> Bus 5:  i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>>    54: eeprom at 54, offset len 1, flags 0
>> Bus 6:  i2c at ff030000->i2c-mux at 74->i2c at 1
>> Bus 7:  i2c at ff030000->i2c-mux at 74->i2c at 2
>> Bus 8:  i2c at ff030000->i2c-mux at 74->i2c at 3
>> Bus 9:  i2c at ff030000->i2c-mux at 74->i2c at 4
>> Bus 10: i2c at ff030000->i2c-mux at 75->i2c at 0
>> Bus 11: i2c at ff030000->i2c-mux at 75->i2c at 1
>> Bus 12: i2c at ff030000->i2c-mux at 75->i2c at 2
>> Bus 13: i2c at ff030000->i2c-mux at 75->i2c at 3
>> Bus 14: i2c at ff030000->i2c-mux at 75->i2c at 4
>> Bus 15: i2c at ff030000->i2c-mux at 75->i2c at 5
>> Bus 16: i2c at ff030000->i2c-mux at 75->i2c at 6
>> Bus 17: i2c at ff030000->i2c-mux at 75->i2c at 7
>>
>> Thanks,
>> Michal
>>
>> Changes in v2:
>> - Update kernel-doc binding
>> - Return -1 in case of error. -1 means that the next free alias is 0.
>> - New patch
>> - New patch
>> - Use dev_read_alias_highest_id()
>> - Use uclass private data
>> - Use private uclass data
>> - Fix headers
>> - Change patch description to focus only on bus name
> 
> I don't have strong objections to this series, but I'd still like to
> try a bit harder on the existing req_seq/seq stuff.
> 
> I don't think we necessarily need to set the 'seq' before probe,
> although I suppose we could.
>
> But is there anything to stop us moving some of the logic which sets
> seq to setting req_seq? We could check the aliases and then set
> req_seq during bind(), perhaps?

Let me put this to my TODO list. But it is not a task which you know
will be done in some hours. It requires to study the whole logic if this
works for all cases.

> This would be better for code size since it would help all subsystems.

This approach is used in the linux kernel that's why there is no way to
get rid of dev_read_alias_highest_id() as function.
It means only i2c_uclass_init() and little code in i2c_post_bind() could
be removed. That's why I don't think we will improve size a lot.
If this is copied to other subsystems then yes it will be more useful.
If we have just one now we can't save a lot.

Heiko: Can you please take a look at this series? I have another 7
patches on the top of this series which depends on it which cleanup all
zynq/zynqmp platforms and I would like to close this to be able to move.

Thanks,
Michal

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-02-05  7:57   ` Michal Simek
@ 2019-02-05  8:20     ` Heiko Schocher
  2019-02-05  9:04       ` Michal Simek
  2019-02-08  4:11     ` Simon Glass
  1 sibling, 1 reply; 40+ messages in thread
From: Heiko Schocher @ 2019-02-05  8:20 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 05.02.2019 um 08:57 schrieb Michal Simek:
> Hi Simon,
> 
> On 02. 02. 19 15:10, Simon Glass wrote:
>> Hi Michal,
>>
>> On Thu, 31 Jan 2019 at 08:31, Michal Simek <michal.simek@xilinx.com> wrote:
>>>
>>> U-Boot with I2C_DM enabled is not capable to list i2c busses connected
>>> to i2c mux. For getting this work there is a need to find out highest
>>> alias ID and use this uniq number for new buses connected to I2C mux.
>>> This series is making this happen.
>>>
>>> There is only one missing piece which is that also i2c controllers which
>>> are not listed in DT are not using this feature.
>>>
>>> Removing setting up aliases from i2c mux code and unifying it in the
>>> same code ensures that numbering schema is proper if no alias is
>>> specified.
>>>
>>> ZynqMP> i2c bus
>>> Bus 0:  i2c at ff020000
>>>     20: gpio at 20, offset len 1, flags 0
>>>     21: gpio at 21, offset len 1, flags 0
>>>     75: i2c-mux at 75, offset len 1, flags 0
>>> Bus 1:  i2c at ff020000->i2c-mux at 75->i2c at 0
>>> Bus 2:  i2c at ff020000->i2c-mux at 75->i2c at 1
>>> Bus 3:  i2c at ff020000->i2c-mux at 75->i2c at 2
>>> Bus 4:  i2c at ff030000  (active 4)
>>>     74: i2c-mux at 74, offset len 1, flags 0
>>>     75: i2c-mux at 75, offset len 1, flags 0
>>> Bus 5:  i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>>>     54: eeprom at 54, offset len 1, flags 0
>>> Bus 6:  i2c at ff030000->i2c-mux at 74->i2c at 1
>>> Bus 7:  i2c at ff030000->i2c-mux at 74->i2c at 2
>>> Bus 8:  i2c at ff030000->i2c-mux at 74->i2c at 3
>>> Bus 9:  i2c at ff030000->i2c-mux at 74->i2c at 4
>>> Bus 10: i2c at ff030000->i2c-mux at 75->i2c at 0
>>> Bus 11: i2c at ff030000->i2c-mux at 75->i2c at 1
>>> Bus 12: i2c at ff030000->i2c-mux at 75->i2c at 2
>>> Bus 13: i2c at ff030000->i2c-mux at 75->i2c at 3
>>> Bus 14: i2c at ff030000->i2c-mux at 75->i2c at 4
>>> Bus 15: i2c at ff030000->i2c-mux at 75->i2c at 5
>>> Bus 16: i2c at ff030000->i2c-mux at 75->i2c at 6
>>> Bus 17: i2c at ff030000->i2c-mux at 75->i2c at 7
>>>
>>> Thanks,
>>> Michal
>>>
>>> Changes in v2:
>>> - Update kernel-doc binding
>>> - Return -1 in case of error. -1 means that the next free alias is 0.
>>> - New patch
>>> - New patch
>>> - Use dev_read_alias_highest_id()
>>> - Use uclass private data
>>> - Use private uclass data
>>> - Fix headers
>>> - Change patch description to focus only on bus name
>>
>> I don't have strong objections to this series, but I'd still like to
>> try a bit harder on the existing req_seq/seq stuff.
>>
>> I don't think we necessarily need to set the 'seq' before probe,
>> although I suppose we could.
>>
>> But is there anything to stop us moving some of the logic which sets
>> seq to setting req_seq? We could check the aliases and then set
>> req_seq during bind(), perhaps?
> 
> Let me put this to my TODO list. But it is not a task which you know
> will be done in some hours. It requires to study the whole logic if this
> works for all cases.

For me it is okay to do this in a second step.

@Simon: Can you give the patcheseries a formal Reviewed-by?

>> This would be better for code size since it would help all subsystems.
> 
> This approach is used in the linux kernel that's why there is no way to
> get rid of dev_read_alias_highest_id() as function.
> It means only i2c_uclass_init() and little code in i2c_post_bind() could
> be removed. That's why I don't think we will improve size a lot.
> If this is copied to other subsystems then yes it will be more useful.
> If we have just one now we can't save a lot.
> 
> Heiko: Can you please take a look at this series? I have another 7
> patches on the top of this series which depends on it which cleanup all
> zynq/zynqmp platforms and I would like to close this to be able to move.

ASAP as I was ill the last 2 weeks ... sorry, give me some time.


bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-02-05  8:20     ` Heiko Schocher
@ 2019-02-05  9:04       ` Michal Simek
  0 siblings, 0 replies; 40+ messages in thread
From: Michal Simek @ 2019-02-05  9:04 UTC (permalink / raw)
  To: u-boot

On 05. 02. 19 9:20, Heiko Schocher wrote:
> Hello Michal,
> 
> Am 05.02.2019 um 08:57 schrieb Michal Simek:
>> Hi Simon,
>>
>> On 02. 02. 19 15:10, Simon Glass wrote:
>>> Hi Michal,
>>>
>>> On Thu, 31 Jan 2019 at 08:31, Michal Simek <michal.simek@xilinx.com>
>>> wrote:
>>>>
>>>> U-Boot with I2C_DM enabled is not capable to list i2c busses connected
>>>> to i2c mux. For getting this work there is a need to find out highest
>>>> alias ID and use this uniq number for new buses connected to I2C mux.
>>>> This series is making this happen.
>>>>
>>>> There is only one missing piece which is that also i2c controllers
>>>> which
>>>> are not listed in DT are not using this feature.
>>>>
>>>> Removing setting up aliases from i2c mux code and unifying it in the
>>>> same code ensures that numbering schema is proper if no alias is
>>>> specified.
>>>>
>>>> ZynqMP> i2c bus
>>>> Bus 0:  i2c at ff020000
>>>>     20: gpio at 20, offset len 1, flags 0
>>>>     21: gpio at 21, offset len 1, flags 0
>>>>     75: i2c-mux at 75, offset len 1, flags 0
>>>> Bus 1:  i2c at ff020000->i2c-mux at 75->i2c at 0
>>>> Bus 2:  i2c at ff020000->i2c-mux at 75->i2c at 1
>>>> Bus 3:  i2c at ff020000->i2c-mux at 75->i2c at 2
>>>> Bus 4:  i2c at ff030000  (active 4)
>>>>     74: i2c-mux at 74, offset len 1, flags 0
>>>>     75: i2c-mux at 75, offset len 1, flags 0
>>>> Bus 5:  i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>>>>     54: eeprom at 54, offset len 1, flags 0
>>>> Bus 6:  i2c at ff030000->i2c-mux at 74->i2c at 1
>>>> Bus 7:  i2c at ff030000->i2c-mux at 74->i2c at 2
>>>> Bus 8:  i2c at ff030000->i2c-mux at 74->i2c at 3
>>>> Bus 9:  i2c at ff030000->i2c-mux at 74->i2c at 4
>>>> Bus 10: i2c at ff030000->i2c-mux at 75->i2c at 0
>>>> Bus 11: i2c at ff030000->i2c-mux at 75->i2c at 1
>>>> Bus 12: i2c at ff030000->i2c-mux at 75->i2c at 2
>>>> Bus 13: i2c at ff030000->i2c-mux at 75->i2c at 3
>>>> Bus 14: i2c at ff030000->i2c-mux at 75->i2c at 4
>>>> Bus 15: i2c at ff030000->i2c-mux at 75->i2c at 5
>>>> Bus 16: i2c at ff030000->i2c-mux at 75->i2c at 6
>>>> Bus 17: i2c at ff030000->i2c-mux at 75->i2c at 7
>>>>
>>>> Thanks,
>>>> Michal
>>>>
>>>> Changes in v2:
>>>> - Update kernel-doc binding
>>>> - Return -1 in case of error. -1 means that the next free alias is 0.
>>>> - New patch
>>>> - New patch
>>>> - Use dev_read_alias_highest_id()
>>>> - Use uclass private data
>>>> - Use private uclass data
>>>> - Fix headers
>>>> - Change patch description to focus only on bus name
>>>
>>> I don't have strong objections to this series, but I'd still like to
>>> try a bit harder on the existing req_seq/seq stuff.
>>>
>>> I don't think we necessarily need to set the 'seq' before probe,
>>> although I suppose we could.
>>>
>>> But is there anything to stop us moving some of the logic which sets
>>> seq to setting req_seq? We could check the aliases and then set
>>> req_seq during bind(), perhaps?
>>
>> Let me put this to my TODO list. But it is not a task which you know
>> will be done in some hours. It requires to study the whole logic if this
>> works for all cases.
> 
> For me it is okay to do this in a second step.
> 
> @Simon: Can you give the patcheseries a formal Reviewed-by?

Thanks for this I wanted Simon to ask about it too.

>>> This would be better for code size since it would help all subsystems.
>>
>> This approach is used in the linux kernel that's why there is no way to
>> get rid of dev_read_alias_highest_id() as function.
>> It means only i2c_uclass_init() and little code in i2c_post_bind() could
>> be removed. That's why I don't think we will improve size a lot.
>> If this is copied to other subsystems then yes it will be more useful.
>> If we have just one now we can't save a lot.
>>
>> Heiko: Can you please take a look at this series? I have another 7
>> patches on the top of this series which depends on it which cleanup all
>> zynq/zynqmp platforms and I would like to close this to be able to move.
> 
> ASAP as I was ill the last 2 weeks ... sorry, give me some time.

Sure.

Thanks,
Michal

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

* [U-Boot] [PATCH v2 1/7] dm: core: Add of_alias_get_highest_id()
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 1/7] dm: core: Add of_alias_get_highest_id() Michal Simek
@ 2019-02-07  6:46   ` Heiko Schocher
  2019-02-08  4:11     ` Simon Glass
  2019-02-11 15:50   ` Heiko Schocher
  1 sibling, 1 reply; 40+ messages in thread
From: Heiko Schocher @ 2019-02-07  6:46 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:30 schrieb Michal Simek:
> The same functionality was added to Linux for i2c bus registration with this
> commit message:
> 
> "
> of: base: add function to get highest id of an alias stem
> 
> I2C supports adding adapters using either a dynamic or fixed id. The
> latter is provided by aliases in the DT case. To prevent id collisions
> of those two types, install this function which gives us the highest
> fixed id, so we can then let the dynamically created ones come after
> this highest number.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Acked-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> "
> 
> Add it also to U-Boot for DM I2C support.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - Update kernel-doc binding
> - Return -1 in case of error. -1 means that the next free alias is 0.
> 
>   drivers/core/of_access.c | 18 ++++++++++++++++++
>   include/dm/of_access.h   | 10 ++++++++++
>   2 files changed, 28 insertions(+)

Looks good to me

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 2/7] fdt: Introduce fdtdec_get_alias_highest_id()
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 2/7] fdt: Introduce fdtdec_get_alias_highest_id() Michal Simek
@ 2019-02-07  6:47   ` Heiko Schocher
  2019-02-08  4:11   ` Simon Glass
  2019-02-11 15:51   ` Heiko Schocher
  2 siblings, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-07  6:47 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:30 schrieb Michal Simek:
> Find out the highest alias ID used for certain subsystem.
> This call will be used for alocating IDs for i2c buses which are not
> described in DT.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2: None
> 
>   include/fdtdec.h | 13 +++++++++++++
>   lib/fdtdec.c     | 33 +++++++++++++++++++++++++++++++++
>   2 files changed, 46 insertions(+)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 3/7] dm: core: Introduce dev_read_alias_highest_id()
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 3/7] dm: core: Introduce dev_read_alias_highest_id() Michal Simek
@ 2019-02-07  6:48   ` Heiko Schocher
  2019-02-08  4:11   ` Simon Glass
  2019-02-11 15:52   ` Heiko Schocher
  2 siblings, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-07  6:48 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:30 schrieb Michal Simek:
> It is wrapper for calling of_alias_get_highest_id() when live tree is
> enabled and fdtdec_get_alias_highest_id() if not.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - New patch
> 
>   drivers/core/read.c |  8 ++++++++
>   include/dm/read.h   | 16 ++++++++++++++++
>   2 files changed, 24 insertions(+)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 4/7] dm: core: Add tests for dev_read_alias_highest_id()
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 4/7] dm: core: Add tests for dev_read_alias_highest_id() Michal Simek
@ 2019-02-07  6:49   ` Heiko Schocher
  2019-02-08  4:11   ` Simon Glass
  2019-02-11 15:52   ` Heiko Schocher
  2 siblings, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-07  6:49 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:31 schrieb Michal Simek:
> It is checking the highest alias ID for eth, gpio, pci, i2c and error
> code on non existing alias.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - New patch
> 
>   test/dm/test-fdt.c | 23 +++++++++++++++++++++++
>   1 file changed, 23 insertions(+)

Thanks for adding tests

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 5/7] i2c: dm: Record maximum id of devices before probing devices
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 5/7] i2c: dm: Record maximum id of devices before probing devices Michal Simek
@ 2019-02-07  6:49   ` Heiko Schocher
  2019-02-11 15:54   ` Heiko Schocher
  1 sibling, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-07  6:49 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:31 schrieb Michal Simek:
> There is a need to find out the first free i2c ID which can be used for
> i2s buses (including i2c buses connected to i2c mux). Do it early in
> init and share this variable with other i2c classes for uniq bus
> identification.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - Use dev_read_alias_highest_id()
> - Use uclass private data
> 
>   drivers/i2c/i2c-uclass.c | 22 ++++++++++++++++++++++
>   1 file changed, 22 insertions(+)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 6/7] i2c: Fill req_seq in i2c_post_bind()
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 6/7] i2c: Fill req_seq in i2c_post_bind() Michal Simek
@ 2019-02-07  6:52   ` Heiko Schocher
  2019-02-11 15:54   ` Heiko Schocher
  1 sibling, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-07  6:52 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:31 schrieb Michal Simek:
> For i2c controllers which are missing alias in DT there is no req_seq
> setup. This function is setting up proper ID based on highest found
> alias ID.
> 
> On zcu102 this is the behavior when patch is applied.
> ZynqMP> i2c bus
> Bus 0:	i2c at ff020000
>     20: gpio at 20, offset len 1, flags 0
>     21: gpio at 21, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 2:	i2c at 0
> Bus 3:	i2c at 1
> Bus 4:	i2c at 2
> Bus 1:	i2c at ff030000  (active 1)
>     74: i2c-mux at 74, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 5:	i2c at 0  (active 5)
>     54: eeprom at 54, offset len 1, flags 0
> Bus 6:	i2c at 1
> Bus 7:	i2c at 2
> Bus 8:	i2c at 3
> Bus 9:	i2c at 4
> Bus 10:	i2c at 0
> Bus 11:	i2c at 1
> Bus 12:	i2c at 2
> Bus 13:	i2c at 3
> Bus 14:	i2c at 4
> Bus 15:	i2c at 5
> Bus 16:	i2c at 6
> Bus 17:	i2c at 7
> 
> Before this patch applied (controllers have -1 ID)
> ZynqMP> i2c bus
> Bus 0:	i2c at ff020000
>     20: gpio at 20, offset len 1, flags 0
>     21: gpio at 21, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus -1:	i2c at 0
> Bus -1:	i2c at 1
> Bus -1:	i2c at 2
> Bus 1:	i2c at ff030000  (active 1)
>     74: i2c-mux at 74, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus -1:	i2c at 0  (active 0)
>     54: eeprom at 54, offset len 1, flags 0
> Bus -1:	i2c at 1
> Bus -1:	i2c at 2
> Bus -1:	i2c at 3
> Bus -1:	i2c at 4
> Bus -1:	i2c at 0
> Bus -1:	i2c at 1
> Bus -1:	i2c at 2
> Bus -1:	i2c at 3
> Bus -1:	i2c at 4
> Bus -1:	i2c at 5
> Bus -1:	i2c at 6
> Bus -1:	i2c at 7
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - Use private uclass data
> 
>   drivers/i2c/i2c-uclass.c | 28 +++++++++++++++++++++++++---
>   1 file changed, 25 insertions(+), 3 deletions(-)

Reviewed-by: Heiko Schocher <hs@denx.de>

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name Michal Simek
  2019-02-02 15:00   ` Simon Glass
@ 2019-02-07  6:55   ` Heiko Schocher
  2019-02-11 15:55   ` Heiko Schocher
  2 siblings, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-07  6:55 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:31 schrieb Michal Simek:
> For !DM case busses are listed as
> ZynqMP> i2c bus
> Bus 0:	zynq_0
> Bus 1:	zynq_0->PCA9544A at 0x75:0
> Bus 2:	zynq_0->PCA9544A at 0x75:1
> Bus 3:	zynq_0->PCA9544A at 0x75:2
> Bus 4:	zynq_1
> Bus 5:	zynq_1->PCA9548 at 0x74:0
> Bus 6:	zynq_1->PCA9548 at 0x74:1
> Bus 7:	zynq_1->PCA9548 at 0x74:2
> Bus 8:	zynq_1->PCA9548 at 0x74:3
> Bus 9:	zynq_1->PCA9548 at 0x74:4
> Bus 10:	zynq_1->PCA9548 at 0x75:0
> Bus 11:	zynq_1->PCA9548 at 0x75:1
> Bus 12:	zynq_1->PCA9548 at 0x75:2
> Bus 13:	zynq_1->PCA9548 at 0x75:3
> Bus 14:	zynq_1->PCA9548 at 0x75:4
> Bus 15:	zynq_1->PCA9548 at 0x75:5
> Bus 16:	zynq_1->PCA9548 at 0x75:6
> Bus 17:	zynq_1->PCA9548 at 0x75:7
> 
> where is exactly describing i2c bus topology.
> By moving to DM case i2c mux buses are using names from DT and because
> i2c-muxes describing sub busses with the same names like i2c at 0, etc it
> is hard to identify which bus is where.
> Linux is adding topology information to i2c-mux busses to identify them
> better.
> This patch is doing the same and composing bus name with topology
> information.
> 
> When patch is applied with topology information on zcu102-revA.
> ZynqMP> i2c bus
> Bus 0:	i2c at ff020000
>     20: gpio at 20, offset len 1, flags 0
>     21: gpio at 21, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 2:	i2c at ff020000->i2c-mux at 75->i2c at 0
> Bus 3:	i2c at ff020000->i2c-mux at 75->i2c at 1
> Bus 4:	i2c at ff020000->i2c-mux at 75->i2c at 2
> Bus 1:	i2c at ff030000  (active 1)
>     74: i2c-mux at 74, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 5:	i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>     54: eeprom at 54, offset len 1, flags 0
> Bus 6:	i2c at ff030000->i2c-mux at 74->i2c at 1
> Bus 7:	i2c at ff030000->i2c-mux at 74->i2c at 2
> Bus 8:	i2c at ff030000->i2c-mux at 74->i2c at 3
> Bus 9:	i2c at ff030000->i2c-mux at 74->i2c at 4
> Bus 10:	i2c at ff030000->i2c-mux at 75->i2c at 0
> Bus 11:	i2c at ff030000->i2c-mux at 75->i2c at 1
> Bus 12:	i2c at ff030000->i2c-mux at 75->i2c at 2
> Bus 13:	i2c at ff030000->i2c-mux at 75->i2c at 3
> Bus 14:	i2c at ff030000->i2c-mux at 75->i2c at 4
> Bus 15:	i2c at ff030000->i2c-mux at 75->i2c at 5
> Bus 16:	i2c at ff030000->i2c-mux at 75->i2c at 6
> Bus 17:	i2c at ff030000->i2c-mux at 75->i2c at 7
> 
> Behavior before the patch is applied.
> ZynqMP> i2c bus
> Bus 0:	i2c at ff020000
>     20: gpio at 20, offset len 1, flags 0
>     21: gpio at 21, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 2:	i2c at 0
> Bus 3:	i2c at 1
> Bus 4:	i2c at 2
> Bus 1:	i2c at ff030000  (active 1)
>     74: i2c-mux at 74, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 5:	i2c at 0  (active 5)
>     54: eeprom at 54, offset len 1, flags 0
> Bus 6:	i2c at 1
> Bus 7:	i2c at 2
> Bus 8:	i2c at 3
> Bus 9:	i2c at 4
> Bus 10:	i2c at 0
> Bus 11:	i2c at 1
> Bus 12:	i2c at 2
> Bus 13:	i2c at 3
> Bus 14:	i2c at 4
> Bus 15:	i2c at 5
> Bus 16:	i2c at 6
> Bus 17:	i2c at 7
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - Fix headers
> - Change patch description to focus only on bus name
> 
>   drivers/i2c/muxes/i2c-mux-uclass.c | 29 ++++++++++++++++++++++++++---
>   1 file changed, 26 insertions(+), 3 deletions(-)

Much more cleaner output, thanks!

Reviewed-by: Heiko Schocher <hs@denx.de>

I have no chance to test this on another hardware, so if someone
could test it, this would be nice.

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 1/7] dm: core: Add of_alias_get_highest_id()
  2019-02-07  6:46   ` Heiko Schocher
@ 2019-02-08  4:11     ` Simon Glass
  0 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2019-02-08  4:11 UTC (permalink / raw)
  To: u-boot

On Wed, 6 Feb 2019 at 23:46, Heiko Schocher <hs@denx.de> wrote:
>
> Hello Michal,
>
> Am 31.01.2019 um 16:30 schrieb Michal Simek:
> > The same functionality was added to Linux for i2c bus registration with this
> > commit message:
> >
> > "
> > of: base: add function to get highest id of an alias stem
> >
> > I2C supports adding adapters using either a dynamic or fixed id. The
> > latter is provided by aliases in the DT case. To prevent id collisions
> > of those two types, install this function which gives us the highest
> > fixed id, so we can then let the dynamically created ones come after
> > this highest number.
> >
> > Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> > Acked-by: Rob Herring <robh@kernel.org>
> > Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> > "
> >
> > Add it also to U-Boot for DM I2C support.
> >
> > Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> > ---
> >
> > Changes in v2:
> > - Update kernel-doc binding
> > - Return -1 in case of error. -1 means that the next free alias is 0.
> >
> >   drivers/core/of_access.c | 18 ++++++++++++++++++
> >   include/dm/of_access.h   | 10 ++++++++++
> >   2 files changed, 28 insertions(+)
>
> Looks good to me
>
> Reviewed-by: Heiko Schocher <hs@denx.de>

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* [U-Boot] [PATCH v2 4/7] dm: core: Add tests for dev_read_alias_highest_id()
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 4/7] dm: core: Add tests for dev_read_alias_highest_id() Michal Simek
  2019-02-07  6:49   ` Heiko Schocher
@ 2019-02-08  4:11   ` Simon Glass
  2019-02-11 15:52   ` Heiko Schocher
  2 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2019-02-08  4:11 UTC (permalink / raw)
  To: u-boot

On Thu, 31 Jan 2019 at 08:31, Michal Simek <michal.simek@xilinx.com> wrote:
>
> It is checking the highest alias ID for eth, gpio, pci, i2c and error
> code on non existing alias.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> Changes in v2:
> - New patch
>
>  test/dm/test-fdt.c | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* [U-Boot] [PATCH v2 2/7] fdt: Introduce fdtdec_get_alias_highest_id()
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 2/7] fdt: Introduce fdtdec_get_alias_highest_id() Michal Simek
  2019-02-07  6:47   ` Heiko Schocher
@ 2019-02-08  4:11   ` Simon Glass
  2019-02-11 15:51   ` Heiko Schocher
  2 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2019-02-08  4:11 UTC (permalink / raw)
  To: u-boot

On Thu, 31 Jan 2019 at 08:31, Michal Simek <michal.simek@xilinx.com> wrote:
>
> Find out the highest alias ID used for certain subsystem.
> This call will be used for alocating IDs for i2c buses which are not
> described in DT.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> Changes in v2: None
>
>  include/fdtdec.h | 13 +++++++++++++
>  lib/fdtdec.c     | 33 +++++++++++++++++++++++++++++++++
>  2 files changed, 46 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* [U-Boot] [PATCH v2 3/7] dm: core: Introduce dev_read_alias_highest_id()
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 3/7] dm: core: Introduce dev_read_alias_highest_id() Michal Simek
  2019-02-07  6:48   ` Heiko Schocher
@ 2019-02-08  4:11   ` Simon Glass
  2019-02-11 15:52   ` Heiko Schocher
  2 siblings, 0 replies; 40+ messages in thread
From: Simon Glass @ 2019-02-08  4:11 UTC (permalink / raw)
  To: u-boot

On Thu, 31 Jan 2019 at 08:31, Michal Simek <michal.simek@xilinx.com> wrote:
>
> It is wrapper for calling of_alias_get_highest_id() when live tree is
> enabled and fdtdec_get_alias_highest_id() if not.
>
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
>
> Changes in v2:
> - New patch
>
>  drivers/core/read.c |  8 ++++++++
>  include/dm/read.h   | 16 ++++++++++++++++
>  2 files changed, 24 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-02-05  7:57   ` Michal Simek
  2019-02-05  8:20     ` Heiko Schocher
@ 2019-02-08  4:11     ` Simon Glass
  2019-02-08  6:45       ` Michal Simek
  1 sibling, 1 reply; 40+ messages in thread
From: Simon Glass @ 2019-02-08  4:11 UTC (permalink / raw)
  To: u-boot

Hi Michal,

On Tue, 5 Feb 2019 at 00:58, Michal Simek <michal.simek@xilinx.com> wrote:
>
> Hi Simon,
>
> On 02. 02. 19 15:10, Simon Glass wrote:
> > Hi Michal,
> >
> > On Thu, 31 Jan 2019 at 08:31, Michal Simek <michal.simek@xilinx.com> wrote:
> >>
> >> U-Boot with I2C_DM enabled is not capable to list i2c busses connected
> >> to i2c mux. For getting this work there is a need to find out highest
> >> alias ID and use this uniq number for new buses connected to I2C mux.
> >> This series is making this happen.
> >>
> >> There is only one missing piece which is that also i2c controllers which
> >> are not listed in DT are not using this feature.
> >>
> >> Removing setting up aliases from i2c mux code and unifying it in the
> >> same code ensures that numbering schema is proper if no alias is
> >> specified.
> >>
> >> ZynqMP> i2c bus
> >> Bus 0:  i2c at ff020000
> >>    20: gpio at 20, offset len 1, flags 0
> >>    21: gpio at 21, offset len 1, flags 0
> >>    75: i2c-mux at 75, offset len 1, flags 0
> >> Bus 1:  i2c at ff020000->i2c-mux at 75->i2c at 0
> >> Bus 2:  i2c at ff020000->i2c-mux at 75->i2c at 1
> >> Bus 3:  i2c at ff020000->i2c-mux at 75->i2c at 2
> >> Bus 4:  i2c at ff030000  (active 4)
> >>    74: i2c-mux at 74, offset len 1, flags 0
> >>    75: i2c-mux at 75, offset len 1, flags 0
> >> Bus 5:  i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
> >>    54: eeprom at 54, offset len 1, flags 0
> >> Bus 6:  i2c at ff030000->i2c-mux at 74->i2c at 1
> >> Bus 7:  i2c at ff030000->i2c-mux at 74->i2c at 2
> >> Bus 8:  i2c at ff030000->i2c-mux at 74->i2c at 3
> >> Bus 9:  i2c at ff030000->i2c-mux at 74->i2c at 4
> >> Bus 10: i2c at ff030000->i2c-mux at 75->i2c at 0
> >> Bus 11: i2c at ff030000->i2c-mux at 75->i2c at 1
> >> Bus 12: i2c at ff030000->i2c-mux at 75->i2c at 2
> >> Bus 13: i2c at ff030000->i2c-mux at 75->i2c at 3
> >> Bus 14: i2c at ff030000->i2c-mux at 75->i2c at 4
> >> Bus 15: i2c at ff030000->i2c-mux at 75->i2c at 5
> >> Bus 16: i2c at ff030000->i2c-mux at 75->i2c at 6
> >> Bus 17: i2c at ff030000->i2c-mux at 75->i2c at 7
> >>
> >> Thanks,
> >> Michal
> >>
> >> Changes in v2:
> >> - Update kernel-doc binding
> >> - Return -1 in case of error. -1 means that the next free alias is 0.
> >> - New patch
> >> - New patch
> >> - Use dev_read_alias_highest_id()
> >> - Use uclass private data
> >> - Use private uclass data
> >> - Fix headers
> >> - Change patch description to focus only on bus name
> >
> > I don't have strong objections to this series, but I'd still like to
> > try a bit harder on the existing req_seq/seq stuff.
> >
> > I don't think we necessarily need to set the 'seq' before probe,
> > although I suppose we could.
> >
> > But is there anything to stop us moving some of the logic which sets
> > seq to setting req_seq? We could check the aliases and then set
> > req_seq during bind(), perhaps?
>
> Let me put this to my TODO list. But it is not a task which you know
> will be done in some hours. It requires to study the whole logic if this
> works for all cases.
>
> > This would be better for code size since it would help all subsystems.
>
> This approach is used in the linux kernel that's why there is no way to
> get rid of dev_read_alias_highest_id() as function.

Yes that function seems useful to me.

> It means only i2c_uclass_init() and little code in i2c_post_bind() could
> be removed. That's why I don't think we will improve size a lot.
> If this is copied to other subsystems then yes it will be more useful.
> If we have just one now we can't save a lot.

Well maybe, but of course the problem you are fixing applies to other
subsystems too, doesn't it?

>
> Heiko: Can you please take a look at this series? I have another 7
> patches on the top of this series which depends on it which cleanup all
> zynq/zynqmp platforms and I would like to close this to be able to move.

Regards,
Simon

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-02-08  4:11     ` Simon Glass
@ 2019-02-08  6:45       ` Michal Simek
  0 siblings, 0 replies; 40+ messages in thread
From: Michal Simek @ 2019-02-08  6:45 UTC (permalink / raw)
  To: u-boot

Hi Simon,

On 08. 02. 19 5:11, Simon Glass wrote:
> Hi Michal,
> 
> On Tue, 5 Feb 2019 at 00:58, Michal Simek <michal.simek@xilinx.com> wrote:
>>
>> Hi Simon,
>>
>> On 02. 02. 19 15:10, Simon Glass wrote:
>>> Hi Michal,
>>>
>>> On Thu, 31 Jan 2019 at 08:31, Michal Simek <michal.simek@xilinx.com> wrote:
>>>>
>>>> U-Boot with I2C_DM enabled is not capable to list i2c busses connected
>>>> to i2c mux. For getting this work there is a need to find out highest
>>>> alias ID and use this uniq number for new buses connected to I2C mux.
>>>> This series is making this happen.
>>>>
>>>> There is only one missing piece which is that also i2c controllers which
>>>> are not listed in DT are not using this feature.
>>>>
>>>> Removing setting up aliases from i2c mux code and unifying it in the
>>>> same code ensures that numbering schema is proper if no alias is
>>>> specified.
>>>>
>>>> ZynqMP> i2c bus
>>>> Bus 0:  i2c at ff020000
>>>>    20: gpio at 20, offset len 1, flags 0
>>>>    21: gpio at 21, offset len 1, flags 0
>>>>    75: i2c-mux at 75, offset len 1, flags 0
>>>> Bus 1:  i2c at ff020000->i2c-mux at 75->i2c at 0
>>>> Bus 2:  i2c at ff020000->i2c-mux at 75->i2c at 1
>>>> Bus 3:  i2c at ff020000->i2c-mux at 75->i2c at 2
>>>> Bus 4:  i2c at ff030000  (active 4)
>>>>    74: i2c-mux at 74, offset len 1, flags 0
>>>>    75: i2c-mux at 75, offset len 1, flags 0
>>>> Bus 5:  i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>>>>    54: eeprom at 54, offset len 1, flags 0
>>>> Bus 6:  i2c at ff030000->i2c-mux at 74->i2c at 1
>>>> Bus 7:  i2c at ff030000->i2c-mux at 74->i2c at 2
>>>> Bus 8:  i2c at ff030000->i2c-mux at 74->i2c at 3
>>>> Bus 9:  i2c at ff030000->i2c-mux at 74->i2c at 4
>>>> Bus 10: i2c at ff030000->i2c-mux at 75->i2c at 0
>>>> Bus 11: i2c at ff030000->i2c-mux at 75->i2c at 1
>>>> Bus 12: i2c at ff030000->i2c-mux at 75->i2c at 2
>>>> Bus 13: i2c at ff030000->i2c-mux at 75->i2c at 3
>>>> Bus 14: i2c at ff030000->i2c-mux at 75->i2c at 4
>>>> Bus 15: i2c at ff030000->i2c-mux at 75->i2c at 5
>>>> Bus 16: i2c at ff030000->i2c-mux at 75->i2c at 6
>>>> Bus 17: i2c at ff030000->i2c-mux at 75->i2c at 7
>>>>
>>>> Thanks,
>>>> Michal
>>>>
>>>> Changes in v2:
>>>> - Update kernel-doc binding
>>>> - Return -1 in case of error. -1 means that the next free alias is 0.
>>>> - New patch
>>>> - New patch
>>>> - Use dev_read_alias_highest_id()
>>>> - Use uclass private data
>>>> - Use private uclass data
>>>> - Fix headers
>>>> - Change patch description to focus only on bus name
>>>
>>> I don't have strong objections to this series, but I'd still like to
>>> try a bit harder on the existing req_seq/seq stuff.
>>>
>>> I don't think we necessarily need to set the 'seq' before probe,
>>> although I suppose we could.
>>>
>>> But is there anything to stop us moving some of the logic which sets
>>> seq to setting req_seq? We could check the aliases and then set
>>> req_seq during bind(), perhaps?
>>
>> Let me put this to my TODO list. But it is not a task which you know
>> will be done in some hours. It requires to study the whole logic if this
>> works for all cases.
>>
>>> This would be better for code size since it would help all subsystems.
>>
>> This approach is used in the linux kernel that's why there is no way to
>> get rid of dev_read_alias_highest_id() as function.
> 
> Yes that function seems useful to me.
> 
>> It means only i2c_uclass_init() and little code in i2c_post_bind() could
>> be removed. That's why I don't think we will improve size a lot.
>> If this is copied to other subsystems then yes it will be more useful.
>> If we have just one now we can't save a lot.
> 
> Well maybe, but of course the problem you are fixing applies to other
> subsystems too, doesn't it?

In Linux i2c came with this solution in connection to DT guys where
aliases are stable and even adding overlay can't update it/change it.

If you grep of_alias_get_highest_id you will find out that there is one
more which is spi and that's it.

This is commit message from Linux regarding spi.

commit 226584aedd94acd61ffa51fb69bcf6b3309a7b8f
Author:     Lucas Stach <l.stach@pengutronix.de>
AuthorDate: Mon Oct 16 12:27:58 2017 +0200
Commit:     Mark Brown <broonie@kernel.org>
CommitDate: Mon Oct 16 21:02:54 2017 +0100

    spi: fix IDR collision on systems with both fixed and dynamic SPI
bus numbers

    On systems where some controllers get a dynamic ID assigned and some
have
    a fixed number from DT, the current implemention might run into an IDR
    collision if the dynamic controllers gets probed first and get an
IDR number,
    which is later requested by the controller with the fixed numbering.
When
    this happens the fixed controller will fail to register with the SPI
core.

    Fix this by skipping all known alias numbers when assigning the
dynamic IDs.

    Fixes: 9b61e302210e (spi: Pick spi bus number from Linux idr or spi
alias)
    Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
    Signed-off-by: Mark Brown <broonie@kernel.org>


Thanks,
Michal


-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190208/f5b0d2ba/attachment.sig>

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-01-31 15:30 [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Michal Simek
                   ` (7 preceding siblings ...)
  2019-02-02 14:10 ` [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Simon Glass
@ 2019-02-08  9:57 ` Heiko Schocher
  2019-02-08 11:14   ` Michal Simek
  8 siblings, 1 reply; 40+ messages in thread
From: Heiko Schocher @ 2019-02-08  9:57 UTC (permalink / raw)
  To: u-boot

Hello Michael,

Am 31.01.2019 um 16:30 schrieb Michal Simek:
> U-Boot with I2C_DM enabled is not capable to list i2c busses connected
> to i2c mux. For getting this work there is a need to find out highest
> alias ID and use this uniq number for new buses connected to I2C mux.
> This series is making this happen.
> 
> There is only one missing piece which is that also i2c controllers which
> are not listed in DT are not using this feature.
> 
> Removing setting up aliases from i2c mux code and unifying it in the
> same code ensures that numbering schema is proper if no alias is
> specified.
> 
> ZynqMP> i2c bus
> Bus 0:	i2c at ff020000
>     20: gpio at 20, offset len 1, flags 0
>     21: gpio at 21, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 1:	i2c at ff020000->i2c-mux at 75->i2c at 0
> Bus 2:	i2c at ff020000->i2c-mux at 75->i2c at 1
> Bus 3:	i2c at ff020000->i2c-mux at 75->i2c at 2
> Bus 4:	i2c at ff030000  (active 4)
>     74: i2c-mux at 74, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 5:	i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>     54: eeprom at 54, offset len 1, flags 0
> Bus 6:	i2c at ff030000->i2c-mux at 74->i2c at 1
> Bus 7:	i2c at ff030000->i2c-mux at 74->i2c at 2
> Bus 8:	i2c at ff030000->i2c-mux at 74->i2c at 3
> Bus 9:	i2c at ff030000->i2c-mux at 74->i2c at 4
> Bus 10:	i2c at ff030000->i2c-mux at 75->i2c at 0
> Bus 11:	i2c at ff030000->i2c-mux at 75->i2c at 1
> Bus 12:	i2c at ff030000->i2c-mux at 75->i2c at 2
> Bus 13:	i2c at ff030000->i2c-mux at 75->i2c at 3
> Bus 14:	i2c at ff030000->i2c-mux at 75->i2c at 4
> Bus 15:	i2c at ff030000->i2c-mux at 75->i2c at 5
> Bus 16:	i2c at ff030000->i2c-mux at 75->i2c at 6
> Bus 17:	i2c at ff030000->i2c-mux at 75->i2c at 7
> 
> Thanks,
> Michal
> 
> Changes in v2:
> - Update kernel-doc binding
> - Return -1 in case of error. -1 means that the next free alias is 0.
> - New patch
> - New patch
> - Use dev_read_alias_highest_id()
> - Use uclass private data
> - Use private uclass data
> - Fix headers
> - Change patch description to focus only on bus name
> 
> Michal Simek (7):
>    dm: core: Add of_alias_get_highest_id()
>    fdt: Introduce fdtdec_get_alias_highest_id()
>    dm: core: Introduce dev_read_alias_highest_id()
>    dm: core: Add tests for dev_read_alias_highest_id()
>    i2c: dm: Record maximum id of devices before probing devices
>    i2c: Fill req_seq in i2c_post_bind()
>    i2c: mux: Generate longer i2c mux name
> 
>   drivers/core/of_access.c           | 18 ++++++++++++++
>   drivers/core/read.c                |  8 ++++++
>   drivers/i2c/i2c-uclass.c           | 50 +++++++++++++++++++++++++++++++++++---
>   drivers/i2c/muxes/i2c-mux-uclass.c | 29 +++++++++++++++++++---
>   include/dm/of_access.h             | 10 ++++++++
>   include/dm/read.h                  | 16 ++++++++++++
>   include/fdtdec.h                   | 13 ++++++++++
>   lib/fdtdec.c                       | 33 +++++++++++++++++++++++++
>   test/dm/test-fdt.c                 | 23 ++++++++++++++++++
>   9 files changed, 194 insertions(+), 6 deletions(-)
> 

I just applied your patches and triggered a build on travis:

It shows error for omap boards:

https://travis-ci.org/hsdenx/u-boot-i2c/jobs/490393822

I try to find time to look into it, but may you have time too?

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-02-08  9:57 ` Heiko Schocher
@ 2019-02-08 11:14   ` Michal Simek
  2019-02-08 11:24     ` Michal Simek
  0 siblings, 1 reply; 40+ messages in thread
From: Michal Simek @ 2019-02-08 11:14 UTC (permalink / raw)
  To: u-boot

On 08. 02. 19 10:57, Heiko Schocher wrote:
> Hello Michael,
> 
> Am 31.01.2019 um 16:30 schrieb Michal Simek:
>> U-Boot with I2C_DM enabled is not capable to list i2c busses connected
>> to i2c mux. For getting this work there is a need to find out highest
>> alias ID and use this uniq number for new buses connected to I2C mux.
>> This series is making this happen.
>>
>> There is only one missing piece which is that also i2c controllers which
>> are not listed in DT are not using this feature.
>>
>> Removing setting up aliases from i2c mux code and unifying it in the
>> same code ensures that numbering schema is proper if no alias is
>> specified.
>>
>> ZynqMP> i2c bus
>> Bus 0:    i2c at ff020000
>>     20: gpio at 20, offset len 1, flags 0
>>     21: gpio at 21, offset len 1, flags 0
>>     75: i2c-mux at 75, offset len 1, flags 0
>> Bus 1:    i2c at ff020000->i2c-mux at 75->i2c at 0
>> Bus 2:    i2c at ff020000->i2c-mux at 75->i2c at 1
>> Bus 3:    i2c at ff020000->i2c-mux at 75->i2c at 2
>> Bus 4:    i2c at ff030000  (active 4)
>>     74: i2c-mux at 74, offset len 1, flags 0
>>     75: i2c-mux at 75, offset len 1, flags 0
>> Bus 5:    i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>>     54: eeprom at 54, offset len 1, flags 0
>> Bus 6:    i2c at ff030000->i2c-mux at 74->i2c at 1
>> Bus 7:    i2c at ff030000->i2c-mux at 74->i2c at 2
>> Bus 8:    i2c at ff030000->i2c-mux at 74->i2c at 3
>> Bus 9:    i2c at ff030000->i2c-mux at 74->i2c at 4
>> Bus 10:    i2c at ff030000->i2c-mux at 75->i2c at 0
>> Bus 11:    i2c at ff030000->i2c-mux at 75->i2c at 1
>> Bus 12:    i2c at ff030000->i2c-mux at 75->i2c at 2
>> Bus 13:    i2c at ff030000->i2c-mux at 75->i2c at 3
>> Bus 14:    i2c at ff030000->i2c-mux at 75->i2c at 4
>> Bus 15:    i2c at ff030000->i2c-mux at 75->i2c at 5
>> Bus 16:    i2c at ff030000->i2c-mux at 75->i2c at 6
>> Bus 17:    i2c at ff030000->i2c-mux at 75->i2c at 7
>>
>> Thanks,
>> Michal
>>
>> Changes in v2:
>> - Update kernel-doc binding
>> - Return -1 in case of error. -1 means that the next free alias is 0.
>> - New patch
>> - New patch
>> - Use dev_read_alias_highest_id()
>> - Use uclass private data
>> - Use private uclass data
>> - Fix headers
>> - Change patch description to focus only on bus name
>>
>> Michal Simek (7):
>>    dm: core: Add of_alias_get_highest_id()
>>    fdt: Introduce fdtdec_get_alias_highest_id()
>>    dm: core: Introduce dev_read_alias_highest_id()
>>    dm: core: Add tests for dev_read_alias_highest_id()
>>    i2c: dm: Record maximum id of devices before probing devices
>>    i2c: Fill req_seq in i2c_post_bind()
>>    i2c: mux: Generate longer i2c mux name
>>
>>   drivers/core/of_access.c           | 18 ++++++++++++++
>>   drivers/core/read.c                |  8 ++++++
>>   drivers/i2c/i2c-uclass.c           | 50
>> +++++++++++++++++++++++++++++++++++---
>>   drivers/i2c/muxes/i2c-mux-uclass.c | 29 +++++++++++++++++++---
>>   include/dm/of_access.h             | 10 ++++++++
>>   include/dm/read.h                  | 16 ++++++++++++
>>   include/fdtdec.h                   | 13 ++++++++++
>>   lib/fdtdec.c                       | 33 +++++++++++++++++++++++++
>>   test/dm/test-fdt.c                 | 23 ++++++++++++++++++
>>   9 files changed, 194 insertions(+), 6 deletions(-)
>>
> 
> I just applied your patches and triggered a build on travis:
> 
> It shows error for omap boards:
> 
> https://travis-ci.org/hsdenx/u-boot-i2c/jobs/490393822
> 
> I try to find time to look into it, but may you have time too?
>

This should be the fix.  (I tried that on omap35_logic_somlv_defconfig)

diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
index 6f3fca2d2326..391fb1289983 100644
--- a/drivers/i2c/i2c-uclass.c
+++ b/drivers/i2c/i2c-uclass.c
@@ -655,8 +655,12 @@ int i2c_uclass_init(struct uclass *class)
        if (!priv)
                return -ENOMEM;

+#if CONFIG_IS_ENABLED(OF_CONTROL)
        /* Get the last allocated alias. */
        priv->max_id = dev_read_alias_highest_id("i2c");
+#else
+       priv->max_id = -1;
+#endif

        debug("%s: highest alias id is %d\n", __func__, priv->max_id);


SPL has no OF_CONTROL and also no LIBFDT that's why it is trying to call
it.

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190208/7fcd5620/attachment.sig>

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-02-08 11:14   ` Michal Simek
@ 2019-02-08 11:24     ` Michal Simek
  2019-02-11  6:20       ` Heiko Schocher
  0 siblings, 1 reply; 40+ messages in thread
From: Michal Simek @ 2019-02-08 11:24 UTC (permalink / raw)
  To: u-boot

On 08. 02. 19 12:14, Michal Simek wrote:
> On 08. 02. 19 10:57, Heiko Schocher wrote:
>> Hello Michael,
>>
>> Am 31.01.2019 um 16:30 schrieb Michal Simek:
>>> U-Boot with I2C_DM enabled is not capable to list i2c busses connected
>>> to i2c mux. For getting this work there is a need to find out highest
>>> alias ID and use this uniq number for new buses connected to I2C mux.
>>> This series is making this happen.
>>>
>>> There is only one missing piece which is that also i2c controllers which
>>> are not listed in DT are not using this feature.
>>>
>>> Removing setting up aliases from i2c mux code and unifying it in the
>>> same code ensures that numbering schema is proper if no alias is
>>> specified.
>>>
>>> ZynqMP> i2c bus
>>> Bus 0:    i2c at ff020000
>>>     20: gpio at 20, offset len 1, flags 0
>>>     21: gpio at 21, offset len 1, flags 0
>>>     75: i2c-mux at 75, offset len 1, flags 0
>>> Bus 1:    i2c at ff020000->i2c-mux at 75->i2c at 0
>>> Bus 2:    i2c at ff020000->i2c-mux at 75->i2c at 1
>>> Bus 3:    i2c at ff020000->i2c-mux at 75->i2c at 2
>>> Bus 4:    i2c at ff030000  (active 4)
>>>     74: i2c-mux at 74, offset len 1, flags 0
>>>     75: i2c-mux at 75, offset len 1, flags 0
>>> Bus 5:    i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>>>     54: eeprom at 54, offset len 1, flags 0
>>> Bus 6:    i2c at ff030000->i2c-mux at 74->i2c at 1
>>> Bus 7:    i2c at ff030000->i2c-mux at 74->i2c at 2
>>> Bus 8:    i2c at ff030000->i2c-mux at 74->i2c at 3
>>> Bus 9:    i2c at ff030000->i2c-mux at 74->i2c at 4
>>> Bus 10:    i2c at ff030000->i2c-mux at 75->i2c at 0
>>> Bus 11:    i2c at ff030000->i2c-mux at 75->i2c at 1
>>> Bus 12:    i2c at ff030000->i2c-mux at 75->i2c at 2
>>> Bus 13:    i2c at ff030000->i2c-mux at 75->i2c at 3
>>> Bus 14:    i2c at ff030000->i2c-mux at 75->i2c at 4
>>> Bus 15:    i2c at ff030000->i2c-mux at 75->i2c at 5
>>> Bus 16:    i2c at ff030000->i2c-mux at 75->i2c at 6
>>> Bus 17:    i2c at ff030000->i2c-mux at 75->i2c at 7
>>>
>>> Thanks,
>>> Michal
>>>
>>> Changes in v2:
>>> - Update kernel-doc binding
>>> - Return -1 in case of error. -1 means that the next free alias is 0.
>>> - New patch
>>> - New patch
>>> - Use dev_read_alias_highest_id()
>>> - Use uclass private data
>>> - Use private uclass data
>>> - Fix headers
>>> - Change patch description to focus only on bus name
>>>
>>> Michal Simek (7):
>>>    dm: core: Add of_alias_get_highest_id()
>>>    fdt: Introduce fdtdec_get_alias_highest_id()
>>>    dm: core: Introduce dev_read_alias_highest_id()
>>>    dm: core: Add tests for dev_read_alias_highest_id()
>>>    i2c: dm: Record maximum id of devices before probing devices
>>>    i2c: Fill req_seq in i2c_post_bind()
>>>    i2c: mux: Generate longer i2c mux name
>>>
>>>   drivers/core/of_access.c           | 18 ++++++++++++++
>>>   drivers/core/read.c                |  8 ++++++
>>>   drivers/i2c/i2c-uclass.c           | 50
>>> +++++++++++++++++++++++++++++++++++---
>>>   drivers/i2c/muxes/i2c-mux-uclass.c | 29 +++++++++++++++++++---
>>>   include/dm/of_access.h             | 10 ++++++++
>>>   include/dm/read.h                  | 16 ++++++++++++
>>>   include/fdtdec.h                   | 13 ++++++++++
>>>   lib/fdtdec.c                       | 33 +++++++++++++++++++++++++
>>>   test/dm/test-fdt.c                 | 23 ++++++++++++++++++
>>>   9 files changed, 194 insertions(+), 6 deletions(-)
>>>
>>
>> I just applied your patches and triggered a build on travis:
>>
>> It shows error for omap boards:
>>
>> https://travis-ci.org/hsdenx/u-boot-i2c/jobs/490393822
>>
>> I try to find time to look into it, but may you have time too?
>>
> 
> This should be the fix.  (I tried that on omap35_logic_somlv_defconfig)
> 
> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
> index 6f3fca2d2326..391fb1289983 100644
> --- a/drivers/i2c/i2c-uclass.c
> +++ b/drivers/i2c/i2c-uclass.c
> @@ -655,8 +655,12 @@ int i2c_uclass_init(struct uclass *class)
>         if (!priv)
>                 return -ENOMEM;
> 
> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>         /* Get the last allocated alias. */
>         priv->max_id = dev_read_alias_highest_id("i2c");
> +#else
> +       priv->max_id = -1;
> +#endif
> 
>         debug("%s: highest alias id is %d\n", __func__, priv->max_id);
> 
> 
> SPL has no OF_CONTROL and also no LIBFDT that's why it is trying to call
> it.

:-) that sentence doesn't make sense. Correction:
...that's why it shouldn't be called.

Maybe it should be enough to have dependency on OF_LIBFDT but Kconfig is
saying that OF_LIBFDT is bool setup to y when OF_CONTROL is enabled.
And in Makefile fdtdec is enabled

obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec.o
or just
obj-$(CONFIG_OF_LIBFDT) += fdtdec.o

Anyway it should be likely enough to have dependency just on OF_LIBFDT.

Thanks,
Michal

-- 
Michal Simek, Ing. (M.Eng), OpenPGP -> KeyID: FE3D1F91
w: www.monstr.eu p: +42-0-721842854
Maintainer of Linux kernel - Xilinx Microblaze
Maintainer of Linux kernel - Xilinx Zynq ARM and ZynqMP ARM64 SoCs
U-Boot custodian - Xilinx Microblaze/Zynq/ZynqMP/Versal SoCs


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190208/5933a337/attachment.sig>

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-02-08 11:24     ` Michal Simek
@ 2019-02-11  6:20       ` Heiko Schocher
  2019-02-11  6:58         ` Michal Simek
  0 siblings, 1 reply; 40+ messages in thread
From: Heiko Schocher @ 2019-02-11  6:20 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 08.02.2019 um 12:24 schrieb Michal Simek:
> On 08. 02. 19 12:14, Michal Simek wrote:
>> On 08. 02. 19 10:57, Heiko Schocher wrote:
>>> Hello Michael,
>>>
>>> Am 31.01.2019 um 16:30 schrieb Michal Simek:
>>>> U-Boot with I2C_DM enabled is not capable to list i2c busses connected
>>>> to i2c mux. For getting this work there is a need to find out highest
>>>> alias ID and use this uniq number for new buses connected to I2C mux.
>>>> This series is making this happen.
>>>>
>>>> There is only one missing piece which is that also i2c controllers which
>>>> are not listed in DT are not using this feature.
>>>>
>>>> Removing setting up aliases from i2c mux code and unifying it in the
>>>> same code ensures that numbering schema is proper if no alias is
>>>> specified.
>>>>
>>>> ZynqMP> i2c bus
>>>> Bus 0:    i2c at ff020000
>>>>      20: gpio at 20, offset len 1, flags 0
>>>>      21: gpio at 21, offset len 1, flags 0
>>>>      75: i2c-mux at 75, offset len 1, flags 0
>>>> Bus 1:    i2c at ff020000->i2c-mux at 75->i2c at 0
>>>> Bus 2:    i2c at ff020000->i2c-mux at 75->i2c at 1
>>>> Bus 3:    i2c at ff020000->i2c-mux at 75->i2c at 2
>>>> Bus 4:    i2c at ff030000  (active 4)
>>>>      74: i2c-mux at 74, offset len 1, flags 0
>>>>      75: i2c-mux at 75, offset len 1, flags 0
>>>> Bus 5:    i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>>>>      54: eeprom at 54, offset len 1, flags 0
>>>> Bus 6:    i2c at ff030000->i2c-mux at 74->i2c at 1
>>>> Bus 7:    i2c at ff030000->i2c-mux at 74->i2c at 2
>>>> Bus 8:    i2c at ff030000->i2c-mux at 74->i2c at 3
>>>> Bus 9:    i2c at ff030000->i2c-mux at 74->i2c at 4
>>>> Bus 10:    i2c at ff030000->i2c-mux at 75->i2c at 0
>>>> Bus 11:    i2c at ff030000->i2c-mux at 75->i2c at 1
>>>> Bus 12:    i2c at ff030000->i2c-mux at 75->i2c at 2
>>>> Bus 13:    i2c at ff030000->i2c-mux at 75->i2c at 3
>>>> Bus 14:    i2c at ff030000->i2c-mux at 75->i2c at 4
>>>> Bus 15:    i2c at ff030000->i2c-mux at 75->i2c at 5
>>>> Bus 16:    i2c at ff030000->i2c-mux at 75->i2c at 6
>>>> Bus 17:    i2c at ff030000->i2c-mux at 75->i2c at 7
>>>>
>>>> Thanks,
>>>> Michal
>>>>
>>>> Changes in v2:
>>>> - Update kernel-doc binding
>>>> - Return -1 in case of error. -1 means that the next free alias is 0.
>>>> - New patch
>>>> - New patch
>>>> - Use dev_read_alias_highest_id()
>>>> - Use uclass private data
>>>> - Use private uclass data
>>>> - Fix headers
>>>> - Change patch description to focus only on bus name
>>>>
>>>> Michal Simek (7):
>>>>     dm: core: Add of_alias_get_highest_id()
>>>>     fdt: Introduce fdtdec_get_alias_highest_id()
>>>>     dm: core: Introduce dev_read_alias_highest_id()
>>>>     dm: core: Add tests for dev_read_alias_highest_id()
>>>>     i2c: dm: Record maximum id of devices before probing devices
>>>>     i2c: Fill req_seq in i2c_post_bind()
>>>>     i2c: mux: Generate longer i2c mux name
>>>>
>>>>    drivers/core/of_access.c           | 18 ++++++++++++++
>>>>    drivers/core/read.c                |  8 ++++++
>>>>    drivers/i2c/i2c-uclass.c           | 50
>>>> +++++++++++++++++++++++++++++++++++---
>>>>    drivers/i2c/muxes/i2c-mux-uclass.c | 29 +++++++++++++++++++---
>>>>    include/dm/of_access.h             | 10 ++++++++
>>>>    include/dm/read.h                  | 16 ++++++++++++
>>>>    include/fdtdec.h                   | 13 ++++++++++
>>>>    lib/fdtdec.c                       | 33 +++++++++++++++++++++++++
>>>>    test/dm/test-fdt.c                 | 23 ++++++++++++++++++
>>>>    9 files changed, 194 insertions(+), 6 deletions(-)
>>>>
>>>
>>> I just applied your patches and triggered a build on travis:
>>>
>>> It shows error for omap boards:
>>>
>>> https://travis-ci.org/hsdenx/u-boot-i2c/jobs/490393822
>>>
>>> I try to find time to look into it, but may you have time too?
>>>
>>
>> This should be the fix.  (I tried that on omap35_logic_somlv_defconfig)
>>
>> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
>> index 6f3fca2d2326..391fb1289983 100644
>> --- a/drivers/i2c/i2c-uclass.c
>> +++ b/drivers/i2c/i2c-uclass.c
>> @@ -655,8 +655,12 @@ int i2c_uclass_init(struct uclass *class)
>>          if (!priv)
>>                  return -ENOMEM;
>>
>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>>          /* Get the last allocated alias. */
>>          priv->max_id = dev_read_alias_highest_id("i2c");
>> +#else
>> +       priv->max_id = -1;
>> +#endif
>>
>>          debug("%s: highest alias id is %d\n", __func__, priv->max_id);
>>
>>
>> SPL has no OF_CONTROL and also no LIBFDT that's why it is trying to call
>> it.
> 
> :-) that sentence doesn't make sense. Correction:
> ...that's why it shouldn't be called.

;-)

> Maybe it should be enough to have dependency on OF_LIBFDT but Kconfig is
> saying that OF_LIBFDT is bool setup to y when OF_CONTROL is enabled.
> And in Makefile fdtdec is enabled
> 
> obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec.o
> or just
> obj-$(CONFIG_OF_LIBFDT) += fdtdec.o
> 
> Anyway it should be likely enough to have dependency just on OF_LIBFDT.

Ok, do you want to send a v3 of the patch:

dm: core: Add of_alias_get_highest_id()

or is it OK for you, if I add the above fix to this patch directly?

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-02-11  6:20       ` Heiko Schocher
@ 2019-02-11  6:58         ` Michal Simek
  2019-02-11  8:45           ` Heiko Schocher
  0 siblings, 1 reply; 40+ messages in thread
From: Michal Simek @ 2019-02-11  6:58 UTC (permalink / raw)
  To: u-boot

On 11. 02. 19 7:20, Heiko Schocher wrote:
> Hello Michal,
> 
> Am 08.02.2019 um 12:24 schrieb Michal Simek:
>> On 08. 02. 19 12:14, Michal Simek wrote:
>>> On 08. 02. 19 10:57, Heiko Schocher wrote:
>>>> Hello Michael,
>>>>
>>>> Am 31.01.2019 um 16:30 schrieb Michal Simek:
>>>>> U-Boot with I2C_DM enabled is not capable to list i2c busses connected
>>>>> to i2c mux. For getting this work there is a need to find out highest
>>>>> alias ID and use this uniq number for new buses connected to I2C mux.
>>>>> This series is making this happen.
>>>>>
>>>>> There is only one missing piece which is that also i2c controllers
>>>>> which
>>>>> are not listed in DT are not using this feature.
>>>>>
>>>>> Removing setting up aliases from i2c mux code and unifying it in the
>>>>> same code ensures that numbering schema is proper if no alias is
>>>>> specified.
>>>>>
>>>>> ZynqMP> i2c bus
>>>>> Bus 0:    i2c at ff020000
>>>>>      20: gpio at 20, offset len 1, flags 0
>>>>>      21: gpio at 21, offset len 1, flags 0
>>>>>      75: i2c-mux at 75, offset len 1, flags 0
>>>>> Bus 1:    i2c at ff020000->i2c-mux at 75->i2c at 0
>>>>> Bus 2:    i2c at ff020000->i2c-mux at 75->i2c at 1
>>>>> Bus 3:    i2c at ff020000->i2c-mux at 75->i2c at 2
>>>>> Bus 4:    i2c at ff030000  (active 4)
>>>>>      74: i2c-mux at 74, offset len 1, flags 0
>>>>>      75: i2c-mux at 75, offset len 1, flags 0
>>>>> Bus 5:    i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>>>>>      54: eeprom at 54, offset len 1, flags 0
>>>>> Bus 6:    i2c at ff030000->i2c-mux at 74->i2c at 1
>>>>> Bus 7:    i2c at ff030000->i2c-mux at 74->i2c at 2
>>>>> Bus 8:    i2c at ff030000->i2c-mux at 74->i2c at 3
>>>>> Bus 9:    i2c at ff030000->i2c-mux at 74->i2c at 4
>>>>> Bus 10:    i2c at ff030000->i2c-mux at 75->i2c at 0
>>>>> Bus 11:    i2c at ff030000->i2c-mux at 75->i2c at 1
>>>>> Bus 12:    i2c at ff030000->i2c-mux at 75->i2c at 2
>>>>> Bus 13:    i2c at ff030000->i2c-mux at 75->i2c at 3
>>>>> Bus 14:    i2c at ff030000->i2c-mux at 75->i2c at 4
>>>>> Bus 15:    i2c at ff030000->i2c-mux at 75->i2c at 5
>>>>> Bus 16:    i2c at ff030000->i2c-mux at 75->i2c at 6
>>>>> Bus 17:    i2c at ff030000->i2c-mux at 75->i2c at 7
>>>>>
>>>>> Thanks,
>>>>> Michal
>>>>>
>>>>> Changes in v2:
>>>>> - Update kernel-doc binding
>>>>> - Return -1 in case of error. -1 means that the next free alias is 0.
>>>>> - New patch
>>>>> - New patch
>>>>> - Use dev_read_alias_highest_id()
>>>>> - Use uclass private data
>>>>> - Use private uclass data
>>>>> - Fix headers
>>>>> - Change patch description to focus only on bus name
>>>>>
>>>>> Michal Simek (7):
>>>>>     dm: core: Add of_alias_get_highest_id()
>>>>>     fdt: Introduce fdtdec_get_alias_highest_id()
>>>>>     dm: core: Introduce dev_read_alias_highest_id()
>>>>>     dm: core: Add tests for dev_read_alias_highest_id()
>>>>>     i2c: dm: Record maximum id of devices before probing devices
>>>>>     i2c: Fill req_seq in i2c_post_bind()
>>>>>     i2c: mux: Generate longer i2c mux name
>>>>>
>>>>>    drivers/core/of_access.c           | 18 ++++++++++++++
>>>>>    drivers/core/read.c                |  8 ++++++
>>>>>    drivers/i2c/i2c-uclass.c           | 50
>>>>> +++++++++++++++++++++++++++++++++++---
>>>>>    drivers/i2c/muxes/i2c-mux-uclass.c | 29 +++++++++++++++++++---
>>>>>    include/dm/of_access.h             | 10 ++++++++
>>>>>    include/dm/read.h                  | 16 ++++++++++++
>>>>>    include/fdtdec.h                   | 13 ++++++++++
>>>>>    lib/fdtdec.c                       | 33 +++++++++++++++++++++++++
>>>>>    test/dm/test-fdt.c                 | 23 ++++++++++++++++++
>>>>>    9 files changed, 194 insertions(+), 6 deletions(-)
>>>>>
>>>>
>>>> I just applied your patches and triggered a build on travis:
>>>>
>>>> It shows error for omap boards:
>>>>
>>>> https://travis-ci.org/hsdenx/u-boot-i2c/jobs/490393822
>>>>
>>>> I try to find time to look into it, but may you have time too?
>>>>
>>>
>>> This should be the fix.  (I tried that on omap35_logic_somlv_defconfig)
>>>
>>> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
>>> index 6f3fca2d2326..391fb1289983 100644
>>> --- a/drivers/i2c/i2c-uclass.c
>>> +++ b/drivers/i2c/i2c-uclass.c
>>> @@ -655,8 +655,12 @@ int i2c_uclass_init(struct uclass *class)
>>>          if (!priv)
>>>                  return -ENOMEM;
>>>
>>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>>>          /* Get the last allocated alias. */
>>>          priv->max_id = dev_read_alias_highest_id("i2c");
>>> +#else
>>> +       priv->max_id = -1;
>>> +#endif
>>>
>>>          debug("%s: highest alias id is %d\n", __func__, priv->max_id);
>>>
>>>
>>> SPL has no OF_CONTROL and also no LIBFDT that's why it is trying to call
>>> it.
>>
>> :-) that sentence doesn't make sense. Correction:
>> ...that's why it shouldn't be called.
> 
> ;-)
> 
>> Maybe it should be enough to have dependency on OF_LIBFDT but Kconfig is
>> saying that OF_LIBFDT is bool setup to y when OF_CONTROL is enabled.
>> And in Makefile fdtdec is enabled
>>
>> obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec.o
>> or just
>> obj-$(CONFIG_OF_LIBFDT) += fdtdec.o
>>
>> Anyway it should be likely enough to have dependency just on OF_LIBFDT.
> 
> Ok, do you want to send a v3 of the patch:
> 
> dm: core: Add of_alias_get_highest_id()
> 
> or is it OK for you, if I add the above fix to this patch directly?

Please take it directly.

M

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-02-11  6:58         ` Michal Simek
@ 2019-02-11  8:45           ` Heiko Schocher
  2019-02-11 10:06             ` Michal Simek
  0 siblings, 1 reply; 40+ messages in thread
From: Heiko Schocher @ 2019-02-11  8:45 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 11.02.2019 um 07:58 schrieb Michal Simek:
> On 11. 02. 19 7:20, Heiko Schocher wrote:
>> Hello Michal,
>>
>> Am 08.02.2019 um 12:24 schrieb Michal Simek:
>>> On 08. 02. 19 12:14, Michal Simek wrote:
>>>> On 08. 02. 19 10:57, Heiko Schocher wrote:
>>>>> Hello Michael,
>>>>>
>>>>> Am 31.01.2019 um 16:30 schrieb Michal Simek:
>>>>>> U-Boot with I2C_DM enabled is not capable to list i2c busses connected
>>>>>> to i2c mux. For getting this work there is a need to find out highest
>>>>>> alias ID and use this uniq number for new buses connected to I2C mux.
>>>>>> This series is making this happen.
>>>>>>
>>>>>> There is only one missing piece which is that also i2c controllers
>>>>>> which
>>>>>> are not listed in DT are not using this feature.
>>>>>>
>>>>>> Removing setting up aliases from i2c mux code and unifying it in the
>>>>>> same code ensures that numbering schema is proper if no alias is
>>>>>> specified.
>>>>>>
>>>>>> ZynqMP> i2c bus
>>>>>> Bus 0:    i2c at ff020000
>>>>>>       20: gpio at 20, offset len 1, flags 0
>>>>>>       21: gpio at 21, offset len 1, flags 0
>>>>>>       75: i2c-mux at 75, offset len 1, flags 0
>>>>>> Bus 1:    i2c at ff020000->i2c-mux at 75->i2c at 0
>>>>>> Bus 2:    i2c at ff020000->i2c-mux at 75->i2c at 1
>>>>>> Bus 3:    i2c at ff020000->i2c-mux at 75->i2c at 2
>>>>>> Bus 4:    i2c at ff030000  (active 4)
>>>>>>       74: i2c-mux at 74, offset len 1, flags 0
>>>>>>       75: i2c-mux at 75, offset len 1, flags 0
>>>>>> Bus 5:    i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>>>>>>       54: eeprom at 54, offset len 1, flags 0
>>>>>> Bus 6:    i2c at ff030000->i2c-mux at 74->i2c at 1
>>>>>> Bus 7:    i2c at ff030000->i2c-mux at 74->i2c at 2
>>>>>> Bus 8:    i2c at ff030000->i2c-mux at 74->i2c at 3
>>>>>> Bus 9:    i2c at ff030000->i2c-mux at 74->i2c at 4
>>>>>> Bus 10:    i2c at ff030000->i2c-mux at 75->i2c at 0
>>>>>> Bus 11:    i2c at ff030000->i2c-mux at 75->i2c at 1
>>>>>> Bus 12:    i2c at ff030000->i2c-mux at 75->i2c at 2
>>>>>> Bus 13:    i2c at ff030000->i2c-mux at 75->i2c at 3
>>>>>> Bus 14:    i2c at ff030000->i2c-mux at 75->i2c at 4
>>>>>> Bus 15:    i2c at ff030000->i2c-mux at 75->i2c at 5
>>>>>> Bus 16:    i2c at ff030000->i2c-mux at 75->i2c at 6
>>>>>> Bus 17:    i2c at ff030000->i2c-mux at 75->i2c at 7
>>>>>>
>>>>>> Thanks,
>>>>>> Michal
>>>>>>
>>>>>> Changes in v2:
>>>>>> - Update kernel-doc binding
>>>>>> - Return -1 in case of error. -1 means that the next free alias is 0.
>>>>>> - New patch
>>>>>> - New patch
>>>>>> - Use dev_read_alias_highest_id()
>>>>>> - Use uclass private data
>>>>>> - Use private uclass data
>>>>>> - Fix headers
>>>>>> - Change patch description to focus only on bus name
>>>>>>
>>>>>> Michal Simek (7):
>>>>>>      dm: core: Add of_alias_get_highest_id()
>>>>>>      fdt: Introduce fdtdec_get_alias_highest_id()
>>>>>>      dm: core: Introduce dev_read_alias_highest_id()
>>>>>>      dm: core: Add tests for dev_read_alias_highest_id()
>>>>>>      i2c: dm: Record maximum id of devices before probing devices
>>>>>>      i2c: Fill req_seq in i2c_post_bind()
>>>>>>      i2c: mux: Generate longer i2c mux name
>>>>>>
>>>>>>     drivers/core/of_access.c           | 18 ++++++++++++++
>>>>>>     drivers/core/read.c                |  8 ++++++
>>>>>>     drivers/i2c/i2c-uclass.c           | 50
>>>>>> +++++++++++++++++++++++++++++++++++---
>>>>>>     drivers/i2c/muxes/i2c-mux-uclass.c | 29 +++++++++++++++++++---
>>>>>>     include/dm/of_access.h             | 10 ++++++++
>>>>>>     include/dm/read.h                  | 16 ++++++++++++
>>>>>>     include/fdtdec.h                   | 13 ++++++++++
>>>>>>     lib/fdtdec.c                       | 33 +++++++++++++++++++++++++
>>>>>>     test/dm/test-fdt.c                 | 23 ++++++++++++++++++
>>>>>>     9 files changed, 194 insertions(+), 6 deletions(-)
>>>>>>
>>>>>
>>>>> I just applied your patches and triggered a build on travis:
>>>>>
>>>>> It shows error for omap boards:
>>>>>
>>>>> https://travis-ci.org/hsdenx/u-boot-i2c/jobs/490393822
>>>>>
>>>>> I try to find time to look into it, but may you have time too?
>>>>>
>>>>
>>>> This should be the fix.  (I tried that on omap35_logic_somlv_defconfig)
>>>>
>>>> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
>>>> index 6f3fca2d2326..391fb1289983 100644
>>>> --- a/drivers/i2c/i2c-uclass.c
>>>> +++ b/drivers/i2c/i2c-uclass.c
>>>> @@ -655,8 +655,12 @@ int i2c_uclass_init(struct uclass *class)
>>>>           if (!priv)
>>>>                   return -ENOMEM;
>>>>
>>>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>>>>           /* Get the last allocated alias. */
>>>>           priv->max_id = dev_read_alias_highest_id("i2c");
>>>> +#else
>>>> +       priv->max_id = -1;
>>>> +#endif
>>>>
>>>>           debug("%s: highest alias id is %d\n", __func__, priv->max_id);
>>>>
>>>>
>>>> SPL has no OF_CONTROL and also no LIBFDT that's why it is trying to call
>>>> it.
>>>
>>> :-) that sentence doesn't make sense. Correction:
>>> ...that's why it shouldn't be called.
>>
>> ;-)
>>
>>> Maybe it should be enough to have dependency on OF_LIBFDT but Kconfig is
>>> saying that OF_LIBFDT is bool setup to y when OF_CONTROL is enabled.
>>> And in Makefile fdtdec is enabled
>>>
>>> obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec.o
>>> or just
>>> obj-$(CONFIG_OF_LIBFDT) += fdtdec.o
>>>
>>> Anyway it should be likely enough to have dependency just on OF_LIBFDT.
>>
>> Ok, do you want to send a v3 of the patch:
>>
>> dm: core: Add of_alias_get_highest_id()
>>
>> or is it OK for you, if I add the above fix to this patch directly?
> 
> Please take it directly.

Ok, done. If all builds fine now, I make a pull request for Tom,
thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux
  2019-02-11  8:45           ` Heiko Schocher
@ 2019-02-11 10:06             ` Michal Simek
  0 siblings, 0 replies; 40+ messages in thread
From: Michal Simek @ 2019-02-11 10:06 UTC (permalink / raw)
  To: u-boot

On 11. 02. 19 9:45, Heiko Schocher wrote:
> Hello Michal,
> 
> Am 11.02.2019 um 07:58 schrieb Michal Simek:
>> On 11. 02. 19 7:20, Heiko Schocher wrote:
>>> Hello Michal,
>>>
>>> Am 08.02.2019 um 12:24 schrieb Michal Simek:
>>>> On 08. 02. 19 12:14, Michal Simek wrote:
>>>>> On 08. 02. 19 10:57, Heiko Schocher wrote:
>>>>>> Hello Michael,
>>>>>>
>>>>>> Am 31.01.2019 um 16:30 schrieb Michal Simek:
>>>>>>> U-Boot with I2C_DM enabled is not capable to list i2c busses
>>>>>>> connected
>>>>>>> to i2c mux. For getting this work there is a need to find out
>>>>>>> highest
>>>>>>> alias ID and use this uniq number for new buses connected to I2C
>>>>>>> mux.
>>>>>>> This series is making this happen.
>>>>>>>
>>>>>>> There is only one missing piece which is that also i2c controllers
>>>>>>> which
>>>>>>> are not listed in DT are not using this feature.
>>>>>>>
>>>>>>> Removing setting up aliases from i2c mux code and unifying it in the
>>>>>>> same code ensures that numbering schema is proper if no alias is
>>>>>>> specified.
>>>>>>>
>>>>>>> ZynqMP> i2c bus
>>>>>>> Bus 0:    i2c at ff020000
>>>>>>>       20: gpio at 20, offset len 1, flags 0
>>>>>>>       21: gpio at 21, offset len 1, flags 0
>>>>>>>       75: i2c-mux at 75, offset len 1, flags 0
>>>>>>> Bus 1:    i2c at ff020000->i2c-mux at 75->i2c at 0
>>>>>>> Bus 2:    i2c at ff020000->i2c-mux at 75->i2c at 1
>>>>>>> Bus 3:    i2c at ff020000->i2c-mux at 75->i2c at 2
>>>>>>> Bus 4:    i2c at ff030000  (active 4)
>>>>>>>       74: i2c-mux at 74, offset len 1, flags 0
>>>>>>>       75: i2c-mux at 75, offset len 1, flags 0
>>>>>>> Bus 5:    i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>>>>>>>       54: eeprom at 54, offset len 1, flags 0
>>>>>>> Bus 6:    i2c at ff030000->i2c-mux at 74->i2c at 1
>>>>>>> Bus 7:    i2c at ff030000->i2c-mux at 74->i2c at 2
>>>>>>> Bus 8:    i2c at ff030000->i2c-mux at 74->i2c at 3
>>>>>>> Bus 9:    i2c at ff030000->i2c-mux at 74->i2c at 4
>>>>>>> Bus 10:    i2c at ff030000->i2c-mux at 75->i2c at 0
>>>>>>> Bus 11:    i2c at ff030000->i2c-mux at 75->i2c at 1
>>>>>>> Bus 12:    i2c at ff030000->i2c-mux at 75->i2c at 2
>>>>>>> Bus 13:    i2c at ff030000->i2c-mux at 75->i2c at 3
>>>>>>> Bus 14:    i2c at ff030000->i2c-mux at 75->i2c at 4
>>>>>>> Bus 15:    i2c at ff030000->i2c-mux at 75->i2c at 5
>>>>>>> Bus 16:    i2c at ff030000->i2c-mux at 75->i2c at 6
>>>>>>> Bus 17:    i2c at ff030000->i2c-mux at 75->i2c at 7
>>>>>>>
>>>>>>> Thanks,
>>>>>>> Michal
>>>>>>>
>>>>>>> Changes in v2:
>>>>>>> - Update kernel-doc binding
>>>>>>> - Return -1 in case of error. -1 means that the next free alias
>>>>>>> is 0.
>>>>>>> - New patch
>>>>>>> - New patch
>>>>>>> - Use dev_read_alias_highest_id()
>>>>>>> - Use uclass private data
>>>>>>> - Use private uclass data
>>>>>>> - Fix headers
>>>>>>> - Change patch description to focus only on bus name
>>>>>>>
>>>>>>> Michal Simek (7):
>>>>>>>      dm: core: Add of_alias_get_highest_id()
>>>>>>>      fdt: Introduce fdtdec_get_alias_highest_id()
>>>>>>>      dm: core: Introduce dev_read_alias_highest_id()
>>>>>>>      dm: core: Add tests for dev_read_alias_highest_id()
>>>>>>>      i2c: dm: Record maximum id of devices before probing devices
>>>>>>>      i2c: Fill req_seq in i2c_post_bind()
>>>>>>>      i2c: mux: Generate longer i2c mux name
>>>>>>>
>>>>>>>     drivers/core/of_access.c           | 18 ++++++++++++++
>>>>>>>     drivers/core/read.c                |  8 ++++++
>>>>>>>     drivers/i2c/i2c-uclass.c           | 50
>>>>>>> +++++++++++++++++++++++++++++++++++---
>>>>>>>     drivers/i2c/muxes/i2c-mux-uclass.c | 29 +++++++++++++++++++---
>>>>>>>     include/dm/of_access.h             | 10 ++++++++
>>>>>>>     include/dm/read.h                  | 16 ++++++++++++
>>>>>>>     include/fdtdec.h                   | 13 ++++++++++
>>>>>>>     lib/fdtdec.c                       | 33
>>>>>>> +++++++++++++++++++++++++
>>>>>>>     test/dm/test-fdt.c                 | 23 ++++++++++++++++++
>>>>>>>     9 files changed, 194 insertions(+), 6 deletions(-)
>>>>>>>
>>>>>>
>>>>>> I just applied your patches and triggered a build on travis:
>>>>>>
>>>>>> It shows error for omap boards:
>>>>>>
>>>>>> https://travis-ci.org/hsdenx/u-boot-i2c/jobs/490393822
>>>>>>
>>>>>> I try to find time to look into it, but may you have time too?
>>>>>>
>>>>>
>>>>> This should be the fix.  (I tried that on
>>>>> omap35_logic_somlv_defconfig)
>>>>>
>>>>> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
>>>>> index 6f3fca2d2326..391fb1289983 100644
>>>>> --- a/drivers/i2c/i2c-uclass.c
>>>>> +++ b/drivers/i2c/i2c-uclass.c
>>>>> @@ -655,8 +655,12 @@ int i2c_uclass_init(struct uclass *class)
>>>>>           if (!priv)
>>>>>                   return -ENOMEM;
>>>>>
>>>>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>>>>>           /* Get the last allocated alias. */
>>>>>           priv->max_id = dev_read_alias_highest_id("i2c");
>>>>> +#else
>>>>> +       priv->max_id = -1;
>>>>> +#endif
>>>>>
>>>>>           debug("%s: highest alias id is %d\n", __func__,
>>>>> priv->max_id);
>>>>>
>>>>>
>>>>> SPL has no OF_CONTROL and also no LIBFDT that's why it is trying to
>>>>> call
>>>>> it.
>>>>
>>>> :-) that sentence doesn't make sense. Correction:
>>>> ...that's why it shouldn't be called.
>>>
>>> ;-)
>>>
>>>> Maybe it should be enough to have dependency on OF_LIBFDT but
>>>> Kconfig is
>>>> saying that OF_LIBFDT is bool setup to y when OF_CONTROL is enabled.
>>>> And in Makefile fdtdec is enabled
>>>>
>>>> obj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec.o
>>>> or just
>>>> obj-$(CONFIG_OF_LIBFDT) += fdtdec.o
>>>>
>>>> Anyway it should be likely enough to have dependency just on OF_LIBFDT.
>>>
>>> Ok, do you want to send a v3 of the patch:
>>>
>>> dm: core: Add of_alias_get_highest_id()
>>>
>>> or is it OK for you, if I add the above fix to this patch directly?
>>
>> Please take it directly.
> 
> Ok, done. If all builds fine now, I make a pull request for Tom,
> thanks!

great.

Thanks.
Michal

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

* [U-Boot] [PATCH v2 1/7] dm: core: Add of_alias_get_highest_id()
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 1/7] dm: core: Add of_alias_get_highest_id() Michal Simek
  2019-02-07  6:46   ` Heiko Schocher
@ 2019-02-11 15:50   ` Heiko Schocher
  1 sibling, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-11 15:50 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:30 schrieb Michal Simek:
> The same functionality was added to Linux for i2c bus registration with this
> commit message:
> 
> "
> of: base: add function to get highest id of an alias stem
> 
> I2C supports adding adapters using either a dynamic or fixed id. The
> latter is provided by aliases in the DT case. To prevent id collisions
> of those two types, install this function which gives us the highest
> fixed id, so we can then let the dynamically created ones come after
> this highest number.
> 
> Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
> Acked-by: Rob Herring <robh@kernel.org>
> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
> "
> 
> Add it also to U-Boot for DM I2C support.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - Update kernel-doc binding
> - Return -1 in case of error. -1 means that the next free alias is 0.
> 
>   drivers/core/of_access.c | 18 ++++++++++++++++++
>   include/dm/of_access.h   | 10 ++++++++++
>   2 files changed, 28 insertions(+)

Applied to u-boot-i2c.git master

Thanks!

bye,
Heiko

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 2/7] fdt: Introduce fdtdec_get_alias_highest_id()
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 2/7] fdt: Introduce fdtdec_get_alias_highest_id() Michal Simek
  2019-02-07  6:47   ` Heiko Schocher
  2019-02-08  4:11   ` Simon Glass
@ 2019-02-11 15:51   ` Heiko Schocher
  2 siblings, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-11 15:51 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:30 schrieb Michal Simek:
> Find out the highest alias ID used for certain subsystem.
> This call will be used for alocating IDs for i2c buses which are not
> described in DT.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2: None
> 
>   include/fdtdec.h | 13 +++++++++++++
>   lib/fdtdec.c     | 33 +++++++++++++++++++++++++++++++++
>   2 files changed, 46 insertions(+)

Applied to u-boot-i2c.git master

Thanks!

bye,
Heiko

-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 3/7] dm: core: Introduce dev_read_alias_highest_id()
  2019-01-31 15:30 ` [U-Boot] [PATCH v2 3/7] dm: core: Introduce dev_read_alias_highest_id() Michal Simek
  2019-02-07  6:48   ` Heiko Schocher
  2019-02-08  4:11   ` Simon Glass
@ 2019-02-11 15:52   ` Heiko Schocher
  2 siblings, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-11 15:52 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:30 schrieb Michal Simek:
> It is wrapper for calling of_alias_get_highest_id() when live tree is
> enabled and fdtdec_get_alias_highest_id() if not.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - New patch
> 
>   drivers/core/read.c |  8 ++++++++
>   include/dm/read.h   | 16 ++++++++++++++++
>   2 files changed, 24 insertions(+)

Applied to u-boot-i2c.git master

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 4/7] dm: core: Add tests for dev_read_alias_highest_id()
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 4/7] dm: core: Add tests for dev_read_alias_highest_id() Michal Simek
  2019-02-07  6:49   ` Heiko Schocher
  2019-02-08  4:11   ` Simon Glass
@ 2019-02-11 15:52   ` Heiko Schocher
  2 siblings, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-11 15:52 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:31 schrieb Michal Simek:
> It is checking the highest alias ID for eth, gpio, pci, i2c and error
> code on non existing alias.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - New patch
> 
>   test/dm/test-fdt.c | 23 +++++++++++++++++++++++
>   1 file changed, 23 insertions(+)

Applied to u-boot-i2c.git master

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 5/7] i2c: dm: Record maximum id of devices before probing devices
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 5/7] i2c: dm: Record maximum id of devices before probing devices Michal Simek
  2019-02-07  6:49   ` Heiko Schocher
@ 2019-02-11 15:54   ` Heiko Schocher
  1 sibling, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-11 15:54 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:31 schrieb Michal Simek:
> There is a need to find out the first free i2c ID which can be used for
> i2s buses (including i2c buses connected to i2c mux). Do it early in
> init and share this variable with other i2c classes for uniq bus
> identification.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - Use dev_read_alias_highest_id()
> - Use uclass private data
> 
>   drivers/i2c/i2c-uclass.c | 22 ++++++++++++++++++++++
>   1 file changed, 22 insertions(+)

Applied to u-boot-i2c.git master

with a fix for build error for omap based boards as discussed.

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 6/7] i2c: Fill req_seq in i2c_post_bind()
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 6/7] i2c: Fill req_seq in i2c_post_bind() Michal Simek
  2019-02-07  6:52   ` Heiko Schocher
@ 2019-02-11 15:54   ` Heiko Schocher
  1 sibling, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-11 15:54 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:31 schrieb Michal Simek:
> For i2c controllers which are missing alias in DT there is no req_seq
> setup. This function is setting up proper ID based on highest found
> alias ID.
> 
> On zcu102 this is the behavior when patch is applied.
> ZynqMP> i2c bus
> Bus 0:	i2c at ff020000
>     20: gpio at 20, offset len 1, flags 0
>     21: gpio at 21, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 2:	i2c at 0
> Bus 3:	i2c at 1
> Bus 4:	i2c at 2
> Bus 1:	i2c at ff030000  (active 1)
>     74: i2c-mux at 74, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 5:	i2c at 0  (active 5)
>     54: eeprom at 54, offset len 1, flags 0
> Bus 6:	i2c at 1
> Bus 7:	i2c at 2
> Bus 8:	i2c at 3
> Bus 9:	i2c at 4
> Bus 10:	i2c at 0
> Bus 11:	i2c at 1
> Bus 12:	i2c at 2
> Bus 13:	i2c at 3
> Bus 14:	i2c at 4
> Bus 15:	i2c at 5
> Bus 16:	i2c at 6
> Bus 17:	i2c at 7
> 
> Before this patch applied (controllers have -1 ID)
> ZynqMP> i2c bus
> Bus 0:	i2c at ff020000
>     20: gpio at 20, offset len 1, flags 0
>     21: gpio at 21, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus -1:	i2c at 0
> Bus -1:	i2c at 1
> Bus -1:	i2c at 2
> Bus 1:	i2c at ff030000  (active 1)
>     74: i2c-mux at 74, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus -1:	i2c at 0  (active 0)
>     54: eeprom at 54, offset len 1, flags 0
> Bus -1:	i2c at 1
> Bus -1:	i2c at 2
> Bus -1:	i2c at 3
> Bus -1:	i2c at 4
> Bus -1:	i2c at 0
> Bus -1:	i2c at 1
> Bus -1:	i2c at 2
> Bus -1:	i2c at 3
> Bus -1:	i2c at 4
> Bus -1:	i2c at 5
> Bus -1:	i2c at 6
> Bus -1:	i2c at 7
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - Use private uclass data
> 
>   drivers/i2c/i2c-uclass.c | 28 +++++++++++++++++++++++++---
>   1 file changed, 25 insertions(+), 3 deletions(-)

Applied to u-boot-i2c.git master

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

* [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name
  2019-01-31 15:31 ` [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name Michal Simek
  2019-02-02 15:00   ` Simon Glass
  2019-02-07  6:55   ` Heiko Schocher
@ 2019-02-11 15:55   ` Heiko Schocher
  2 siblings, 0 replies; 40+ messages in thread
From: Heiko Schocher @ 2019-02-11 15:55 UTC (permalink / raw)
  To: u-boot

Hello Michal,

Am 31.01.2019 um 16:31 schrieb Michal Simek:
> For !DM case busses are listed as
> ZynqMP> i2c bus
> Bus 0:	zynq_0
> Bus 1:	zynq_0->PCA9544A at 0x75:0
> Bus 2:	zynq_0->PCA9544A at 0x75:1
> Bus 3:	zynq_0->PCA9544A at 0x75:2
> Bus 4:	zynq_1
> Bus 5:	zynq_1->PCA9548 at 0x74:0
> Bus 6:	zynq_1->PCA9548 at 0x74:1
> Bus 7:	zynq_1->PCA9548 at 0x74:2
> Bus 8:	zynq_1->PCA9548 at 0x74:3
> Bus 9:	zynq_1->PCA9548 at 0x74:4
> Bus 10:	zynq_1->PCA9548 at 0x75:0
> Bus 11:	zynq_1->PCA9548 at 0x75:1
> Bus 12:	zynq_1->PCA9548 at 0x75:2
> Bus 13:	zynq_1->PCA9548 at 0x75:3
> Bus 14:	zynq_1->PCA9548 at 0x75:4
> Bus 15:	zynq_1->PCA9548 at 0x75:5
> Bus 16:	zynq_1->PCA9548 at 0x75:6
> Bus 17:	zynq_1->PCA9548 at 0x75:7
> 
> where is exactly describing i2c bus topology.
> By moving to DM case i2c mux buses are using names from DT and because
> i2c-muxes describing sub busses with the same names like i2c at 0, etc it
> is hard to identify which bus is where.
> Linux is adding topology information to i2c-mux busses to identify them
> better.
> This patch is doing the same and composing bus name with topology
> information.
> 
> When patch is applied with topology information on zcu102-revA.
> ZynqMP> i2c bus
> Bus 0:	i2c at ff020000
>     20: gpio at 20, offset len 1, flags 0
>     21: gpio at 21, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 2:	i2c at ff020000->i2c-mux at 75->i2c at 0
> Bus 3:	i2c at ff020000->i2c-mux at 75->i2c at 1
> Bus 4:	i2c at ff020000->i2c-mux at 75->i2c at 2
> Bus 1:	i2c at ff030000  (active 1)
>     74: i2c-mux at 74, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 5:	i2c at ff030000->i2c-mux at 74->i2c at 0  (active 5)
>     54: eeprom at 54, offset len 1, flags 0
> Bus 6:	i2c at ff030000->i2c-mux at 74->i2c at 1
> Bus 7:	i2c at ff030000->i2c-mux at 74->i2c at 2
> Bus 8:	i2c at ff030000->i2c-mux at 74->i2c at 3
> Bus 9:	i2c at ff030000->i2c-mux at 74->i2c at 4
> Bus 10:	i2c at ff030000->i2c-mux at 75->i2c at 0
> Bus 11:	i2c at ff030000->i2c-mux at 75->i2c at 1
> Bus 12:	i2c at ff030000->i2c-mux at 75->i2c at 2
> Bus 13:	i2c at ff030000->i2c-mux at 75->i2c at 3
> Bus 14:	i2c at ff030000->i2c-mux at 75->i2c at 4
> Bus 15:	i2c at ff030000->i2c-mux at 75->i2c at 5
> Bus 16:	i2c at ff030000->i2c-mux at 75->i2c at 6
> Bus 17:	i2c at ff030000->i2c-mux at 75->i2c at 7
> 
> Behavior before the patch is applied.
> ZynqMP> i2c bus
> Bus 0:	i2c at ff020000
>     20: gpio at 20, offset len 1, flags 0
>     21: gpio at 21, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 2:	i2c at 0
> Bus 3:	i2c at 1
> Bus 4:	i2c at 2
> Bus 1:	i2c at ff030000  (active 1)
>     74: i2c-mux at 74, offset len 1, flags 0
>     75: i2c-mux at 75, offset len 1, flags 0
> Bus 5:	i2c at 0  (active 5)
>     54: eeprom at 54, offset len 1, flags 0
> Bus 6:	i2c at 1
> Bus 7:	i2c at 2
> Bus 8:	i2c at 3
> Bus 9:	i2c at 4
> Bus 10:	i2c at 0
> Bus 11:	i2c at 1
> Bus 12:	i2c at 2
> Bus 13:	i2c at 3
> Bus 14:	i2c at 4
> Bus 15:	i2c at 5
> Bus 16:	i2c at 6
> Bus 17:	i2c at 7
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>
> ---
> 
> Changes in v2:
> - Fix headers
> - Change patch description to focus only on bus name
> 
>   drivers/i2c/muxes/i2c-mux-uclass.c | 29 ++++++++++++++++++++++++++---
>   1 file changed, 26 insertions(+), 3 deletions(-)

Applied to u-boot-i2c.git master

Thanks!

bye,
Heiko
-- 
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: hs at denx.de

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

end of thread, other threads:[~2019-02-11 15:55 UTC | newest]

Thread overview: 40+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-31 15:30 [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Michal Simek
2019-01-31 15:30 ` [U-Boot] [PATCH v2 1/7] dm: core: Add of_alias_get_highest_id() Michal Simek
2019-02-07  6:46   ` Heiko Schocher
2019-02-08  4:11     ` Simon Glass
2019-02-11 15:50   ` Heiko Schocher
2019-01-31 15:30 ` [U-Boot] [PATCH v2 2/7] fdt: Introduce fdtdec_get_alias_highest_id() Michal Simek
2019-02-07  6:47   ` Heiko Schocher
2019-02-08  4:11   ` Simon Glass
2019-02-11 15:51   ` Heiko Schocher
2019-01-31 15:30 ` [U-Boot] [PATCH v2 3/7] dm: core: Introduce dev_read_alias_highest_id() Michal Simek
2019-02-07  6:48   ` Heiko Schocher
2019-02-08  4:11   ` Simon Glass
2019-02-11 15:52   ` Heiko Schocher
2019-01-31 15:31 ` [U-Boot] [PATCH v2 4/7] dm: core: Add tests for dev_read_alias_highest_id() Michal Simek
2019-02-07  6:49   ` Heiko Schocher
2019-02-08  4:11   ` Simon Glass
2019-02-11 15:52   ` Heiko Schocher
2019-01-31 15:31 ` [U-Boot] [PATCH v2 5/7] i2c: dm: Record maximum id of devices before probing devices Michal Simek
2019-02-07  6:49   ` Heiko Schocher
2019-02-11 15:54   ` Heiko Schocher
2019-01-31 15:31 ` [U-Boot] [PATCH v2 6/7] i2c: Fill req_seq in i2c_post_bind() Michal Simek
2019-02-07  6:52   ` Heiko Schocher
2019-02-11 15:54   ` Heiko Schocher
2019-01-31 15:31 ` [U-Boot] [PATCH v2 7/7] i2c: mux: Generate longer i2c mux name Michal Simek
2019-02-02 15:00   ` Simon Glass
2019-02-07  6:55   ` Heiko Schocher
2019-02-11 15:55   ` Heiko Schocher
2019-02-02 14:10 ` [U-Boot] [PATCH v2 0/7] Align U-Boot I2C DM bus ID handling with Linux Simon Glass
2019-02-05  7:57   ` Michal Simek
2019-02-05  8:20     ` Heiko Schocher
2019-02-05  9:04       ` Michal Simek
2019-02-08  4:11     ` Simon Glass
2019-02-08  6:45       ` Michal Simek
2019-02-08  9:57 ` Heiko Schocher
2019-02-08 11:14   ` Michal Simek
2019-02-08 11:24     ` Michal Simek
2019-02-11  6:20       ` Heiko Schocher
2019-02-11  6:58         ` Michal Simek
2019-02-11  8:45           ` Heiko Schocher
2019-02-11 10:06             ` Michal Simek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.