Align U-Boot I2C DM bus ID handling with Linux
Subsystems (3)
v2 cover Align U-Boot I2C DM bus ID handling with Linux
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(-)
Signature · 1 line
1.9.1
PATCH v2 1/7 dm: core: Add of_alias_get_highest_id()
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.
"
Add it also to U-Boot for DM I2C support.
---
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(+)
drivers/core/of_access.c +18 -0
@@ -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;
include/dm/of_access.h +10 -0
@@ -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
Signature · 1 line
1.9.1
PATCH v2 2/7 fdt: Introduce fdtdec_get_alias_highest_id()
In reply to Michal SimekFind 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.
---
Changes in v2: None
include/fdtdec.h | 13 +++++++++++++ lib/fdtdec.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
include/fdtdec.h +13 -0
@@ -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)
lib/fdtdec.c +33 -0
@@ -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;
Signature · 1 line
1.9.1
PATCH v2 3/7 dm: core: Introduce dev_read_alias_highest_id()
In reply to Michal SimekIt is wrapper for calling of_alias_get_highest_id() when live tree is enabled and fdtdec_get_alias_highest_id() if not.
---
Changes in v2:
- New patch
drivers/core/read.c | 8 ++++++++ include/dm/read.h | 16 ++++++++++++++++ 2 files changed, 24 insertions(+)
drivers/core/read.c +8 -0
@@ -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); +}
include/dm/read.h +16 -0
@@ -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 */ /**
Signature · 1 line
1.9.1
PATCH v2 4/7 dm: core: Add tests for dev_read_alias_highest_id()
In reply to Michal SimekIt is checking the highest alias ID for eth, gpio, pci, i2c and error code on non existing alias.
---
Changes in v2:
- New patch
test/dm/test-fdt.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
test/dm/test-fdt.c +23 -0
@@ -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;
Signature · 1 line
1.9.1
PATCH v2 5/7 i2c: dm: Record maximum id of devices before probing devices
In reply to Michal SimekThere 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.
---
Changes in v2:
- Use dev_read_alias_highest_id()
- Use uclass private data
drivers/i2c/i2c-uclass.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
drivers/i2c/i2c-uclass.c +22 -0
@@ -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),
Signature · 1 line
1.9.1
PATCH v2 6/7 i2c: Fill req_seq in i2c_post_bind()
In reply to Michal SimekFor 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
---
Changes in v2:
- Use private uclass data
drivers/i2c/i2c-uclass.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
drivers/i2c/i2c-uclass.c +25 -3
@@ -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,
Signature · 1 line
1.9.1
PATCH v2 7/7 i2c: mux: Generate longer i2c mux name
In reply to Michal SimekFor !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
---
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(-)
drivers/i2c/muxes/i2c-mux-uclass.c +26 -3
@@ -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; }
Signature · 1 line
1.9.1
v2 cover Align U-Boot I2C DM bus ID handling with Linux
In reply to Michal SimekHi Michal,
Quoted 42 lines · Michal Simek
U-Boot with
I2C_DMenabled 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 atff020000
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 0Bus 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 0Bus 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 7Thanks,
Michal
Quoted 10 lines
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
- Usedev_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
PATCH v2 7/7 i2c: mux: Generate longer i2c mux name
In reply to Michal SimekQuoted 86 lines · Michal Simek
For !DM case busses are listed as
ZynqMP> i2c busBus 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:7where 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 atff020000
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 0Bus 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 0Bus 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 7Behavior before the patch is applied.
ZynqMP> i2c bus
Bus 0: i2c atff020000
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 0Bus 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 0Bus 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 7Signed-off-by Michal Simek <[email protected]>
Quoted 8 lines
---
Changes in v2:
- Fix headers
- Change patch description to focus only on bus namedrivers/i2c/muxes/i2c-mux-uclass.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
v2 cover Align U-Boot I2C DM bus ID handling with Linux
In reply to Simon GlassHi Simon,
Quoted 59 lines · Simon Glass
Hi Michal,
Quoted 42 lines · Michal Simek
U-Boot with
I2C_DMenabled 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 atff020000
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 0Bus 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 0Bus 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 7Thanks,
MichalQuoted 10 lines
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
- Usedev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus nameI 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.
Quoted 6 lines
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 setreq_seqduringbind(), 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.
Quoted 1 line
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
v2 cover Align U-Boot I2C DM bus ID handling with Linux
Hello Michal,
Am 05.02.2019 um 08:57 schrieb Michal Simek:
Quoted 65 lines
Hi Simon,
Quoted 62 lines · Simon Glass
Hi Michal,
Quoted 42 lines · Michal Simek
U-Boot with
I2C_DMenabled 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 atff020000
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 0Bus 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 7Thanks,
MichalQuoted 10 lines
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
- Usedev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus nameI 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.
Quoted 7 lines
Quoted 3 lines
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 setreq_seqduringbind(), 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?
Quoted 9 lines
Quoted 1 line
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 onlyi2c_uclass_init()and little code ini2c_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.
Quoted 3 lines
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
Signature · 3 lines
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
v2 cover Align U-Boot I2C DM bus ID handling with Linux
Quoted 74 lines · Heiko Schocher
Hello Michal,
Am 05.02.2019 um 08:57 schrieb Michal Simek:
Quoted 71 lines
Hi Simon,
Quoted 67 lines · Simon Glass
Hi Michal,
Quoted 43 lines · Michal Simek
U-Boot with
I2C_DMenabled 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 atff020000
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 7Thanks,
MichalQuoted 10 lines
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
- Usedev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus nameI 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 setreq_seqduringbind(), perhaps?
Quoted 7 lines
Quoted 3 lines
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.
Quoted 9 lines
Quoted 9 lines
Quoted 1 line
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 onlyi2c_uclass_init()and little code ini2c_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.
Quoted 5 lines
Quoted 3 lines
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
PATCH v2 1/7 dm: core: Add of_alias_get_highest_id()
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 22 lines
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 stemI2C 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 <[email protected]>Acked-by Rob Herring <[email protected]>Signed-off-by Wolfram Sang <[email protected]>"
Add it also to U-Boot for DM I2C support.
Signed-off-by Michal Simek <[email protected]>---
Quoted 7 lines
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
bye,
Heiko
Signature · 3 lines
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
PATCH v2 2/7 fdt: Introduce fdtdec_get_alias_highest_id()
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 4 lines
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.
Quoted 8 lines
Signed-off-by Michal Simek <[email protected]>---
Changes in v2: None
include/fdtdec.h | 13 +++++++++++++ lib/fdtdec.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
bye,
Heiko
Signature · 3 lines
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
PATCH v2 3/7 dm: core: Introduce dev_read_alias_highest_id()
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 4 lines
It is wrapper for calling
of_alias_get_highest_id()when live tree is enabled andfdtdec_get_alias_highest_id()if not.Signed-off-by Michal Simek <[email protected]>
Quoted 8 lines
---
Changes in v2:
- New patchdrivers/core/read.c | 8 ++++++++ include/dm/read.h | 16 ++++++++++++++++ 2 files changed, 24 insertions(+)
bye,
Heiko
Signature · 3 lines
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
PATCH v2 4/7 dm: core: Add tests for dev_read_alias_highest_id()
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:31 schrieb Michal Simek:
Quoted 11 lines
It is checking the highest alias ID for eth, gpio, pci, i2c and error code on non existing alias.
Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- New patchtest/dm/test-fdt.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
Thanks for adding tests
bye,
Heiko
Signature · 3 lines
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
PATCH v2 5/7 i2c: dm: Record maximum id of devices before probing devices
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:31 schrieb Michal Simek:
Quoted 6 lines
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 <[email protected]>
Quoted 8 lines
---
Changes in v2:
- Usedev_read_alias_highest_id()
- Use uclass private datadrivers/i2c/i2c-uclass.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
bye,
Heiko
Signature · 3 lines
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
PATCH v2 6/7 i2c: Fill req_seq in i2c_post_bind()
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:31 schrieb Michal Simek:
Quoted 58 lines
For i2c controllers which are missing alias in DT there is no
req_seqsetup. 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 atff020000
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 atff030000(active 1)74: i2c-mux at 74, offset len 1, flags 0 75: i2c-mux at 75, offset len 1, flags 0Bus 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 7Before this patch applied (controllers have -1 ID) ZynqMP> i2c bus
Bus 0: i2c atff020000
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 atff030000(active 1)74: i2c-mux at 74, offset len 1, flags 0 75: i2c-mux at 75, offset len 1, flags 0Bus -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
Quoted 8 lines
Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- Use private uclass datadrivers/i2c/i2c-uclass.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
bye,
Heiko
Signature · 3 lines
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
PATCH v2 7/7 i2c: mux: Generate longer i2c mux name
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:31 schrieb Michal Simek:
Quoted 85 lines
For !DM case busses are listed as
ZynqMP> i2c bus
Bus 0:zynq_0
Bus 1:zynq_0->PCA9544Aat 0x75:0
Bus 2:zynq_0->PCA9544Aat 0x75:1
Bus 3:zynq_0->PCA9544Aat 0x75:2
Bus 4:zynq_1
Bus 5:zynq_1->PCA9548at 0x74:0
Bus 6:zynq_1->PCA9548at 0x74:1
Bus 7:zynq_1->PCA9548at 0x74:2
Bus 8:zynq_1->PCA9548at 0x74:3
Bus 9:zynq_1->PCA9548at 0x74:4
Bus 10:zynq_1->PCA9548at 0x75:0
Bus 11:zynq_1->PCA9548at 0x75:1
Bus 12:zynq_1->PCA9548at 0x75:2
Bus 13:zynq_1->PCA9548at 0x75:3
Bus 14:zynq_1->PCA9548at 0x75:4
Bus 15:zynq_1->PCA9548at 0x75:5
Bus 16:zynq_1->PCA9548at 0x75:6
Bus 17:zynq_1->PCA9548at 0x75:7where 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 atff020000
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 atff030000(active 1)74: i2c-mux at 74, offset len 1, flags 0 75: i2c-mux at 75, offset len 1, flags 0Bus 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 7Behavior before the patch is applied.
ZynqMP> i2c bus
Bus 0: i2c atff020000
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 atff030000(active 1)74: i2c-mux at 74, offset len 1, flags 0 75: i2c-mux at 75, offset len 1, flags 0Bus 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 7Signed-off-by Michal Simek <[email protected]>
Quoted 8 lines
---
Changes in v2:
- Fix headers
- Change patch description to focus only on bus namedrivers/i2c/muxes/i2c-mux-uclass.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
Much more cleaner output, thanks!
I have no chance to test this on another hardware, so if someone could test it, this would be nice.
bye,
Heiko
Signature · 3 lines
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
PATCH v2 1/7 dm: core: Add of_alias_get_highest_id()
In reply to Heiko SchocherQuoted 30 lines · Heiko Schocher
Hello Michal,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 26 lines
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 stemI2C 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 <[email protected]>Acked-by Rob Herring <[email protected]>Signed-off-by Wolfram Sang <[email protected]>"
Add it also to U-Boot for DM I2C support.
Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- Update kernel-doc binding
- Return -1 in case of error. -1 means that the next free alias is 0.
Quoted 7 lines
Quoted 3 lines
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 <[email protected]>
PATCH v2 4/7 dm: core: Add tests for dev_read_alias_highest_id()
In reply to Michal SimekQuoted 4 lines · Michal Simek
It is checking the highest alias ID for eth, gpio, pci, i2c and error code on non existing alias.
Quoted 8 lines
Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- New patchtest/dm/test-fdt.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
PATCH v2 2/7 fdt: Introduce fdtdec_get_alias_highest_id()
In reply to Michal SimekQuoted 5 lines · 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.
Quoted 8 lines
Signed-off-by Michal Simek <[email protected]>---
Changes in v2: None
include/fdtdec.h | 13 +++++++++++++ lib/fdtdec.c | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+)
PATCH v2 3/7 dm: core: Introduce dev_read_alias_highest_id()
In reply to Michal SimekQuoted 5 lines · Michal Simek
It is wrapper for calling
of_alias_get_highest_id()when live tree is enabled andfdtdec_get_alias_highest_id()if not.Signed-off-by Michal Simek <[email protected]>
Quoted 8 lines
---
Changes in v2:
- New patchdrivers/core/read.c | 8 ++++++++ include/dm/read.h | 16 ++++++++++++++++ 2 files changed, 24 insertions(+)
v2 cover Align U-Boot I2C DM bus ID handling with Linux
In reply to Michal SimekHi Michal,
Quoted 70 lines · Michal Simek
Hi Simon,
Quoted 59 lines · Simon Glass
Hi Michal,
Quoted 42 lines · Michal Simek
U-Boot with
I2C_DMenabled 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 atff020000
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 0Bus 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 0Bus 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 7Thanks,
MichalQuoted 10 lines
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
- Usedev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus nameI 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.
Quoted 6 lines
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 setreq_seqduringbind(), perhaps?
Quoted 8 lines
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.
Quoted 1 line
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.
Quoted 4 lines
It means only
i2c_uclass_init()and little code ini2c_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?
Quoted 4 lines
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
v2 cover Align U-Boot I2C DM bus ID handling with Linux
Hi Simon,
Quoted 84 lines · Simon Glass
Hi Michal,
Quoted 70 lines · Michal Simek
Hi Simon,
Quoted 59 lines · Simon Glass
Hi Michal,
Quoted 42 lines · Michal Simek
U-Boot with
I2C_DMenabled 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 atff020000
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 0Bus 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 0Bus 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 7Thanks,
MichalQuoted 10 lines
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
- Usedev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus nameI 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.
Quoted 6 lines
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 setreq_seqduringbind(), perhaps?Quoted 8 lines
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.
Quoted 1 line
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.
Quoted 7 lines
Quoted 4 lines
It means only
i2c_uclass_init()and little code ini2c_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 <[email protected]> AuthorDate: Mon Oct 16 12:27:58 2017 +0200 Commit: Mark Brown <[email protected]> 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.
alias)
Thanks,
Michal
Signature · 14 lines
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>
v2 cover Align U-Boot I2C DM bus ID handling with Linux
In reply to Michal SimekHello Michael,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 61 lines
U-Boot with
I2C_DMenabled 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 atff020000
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 atff030000(active 4)74: i2c-mux at 74, offset len 1, flags 0 75: i2c-mux at 75, offset len 1, flags 0Bus 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 7Thanks,
MichalChanges 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
- Usedev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus nameMichal Simek (7):
dm: core: Addof_alias_get_highest_id()
fdt: Introducefdtdec_get_alias_highest_id()
dm: core: Introducedev_read_alias_highest_id()
dm: core: Add tests fordev_read_alias_highest_id()
i2c: dm: Record maximum id of devices before probing devices
i2c: Fillreq_seqini2c_post_bind()
i2c: mux: Generate longer i2c mux name
Quoted 11 lines
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
Signature · 3 lines
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
v2 cover Align U-Boot I2C DM bus ID handling with Linux
Quoted 77 lines · Heiko Schocher
Hello Michael,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 71 lines
U-Boot with
I2C_DMenabled 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 atff020000
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 7Thanks,
MichalChanges 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
- Usedev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus nameMichal Simek (7):
dm: core: Addof_alias_get_highest_id()
fdt: Introducefdtdec_get_alias_highest_id()
dm: core: Introducedev_read_alias_highest_id()
dm: core: Add tests fordev_read_alias_highest_id()
i2c: dm: Record maximum id of devices before probing devices
i2c: Fillreq_seqini2c_post_bind()
i2c: mux: Generate longer i2c mux namedrivers/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 ++++++++++++++++++Quoted 2 lines
9 files changed, 194 insertions(+), 6 deletions(-)
Quoted 8 lines
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)
drivers/i2c/i2c-uclass.c +4 -0
@@ -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
Signature · 14 lines
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>
v2 cover Align U-Boot I2C DM bus ID handling with Linux
Quoted 107 lines · Michal Simek
Quoted 77 lines · Heiko Schocher
Hello Michael,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 71 lines
U-Boot with
I2C_DMenabled 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 atff020000
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 7Thanks,
MichalChanges 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
- Usedev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus nameMichal Simek (7):
dm: core: Addof_alias_get_highest_id()
fdt: Introducefdtdec_get_alias_highest_id()
dm: core: Introducedev_read_alias_highest_id()
dm: core: Add tests fordev_read_alias_highest_id()
i2c: dm: Record maximum id of devices before probing devices
i2c: Fillreq_seqini2c_post_bind()
i2c: mux: Generate longer i2c mux namedrivers/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 ++++++++++++++++++Quoted 2 lines
9 files changed, 194 insertions(+), 6 deletions(-)Quoted 8 lines
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)drivers/i2c/i2c-uclass.c +4
-0@@ -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);
Quoted 2 lines
SPL has no
OF_CONTROLand 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
Signature · 14 lines
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>
v2 cover Align U-Boot I2C DM bus ID handling with Linux
Hello Michal,
Am 08.02.2019 um 12:24 schrieb Michal Simek:
Quoted 105 lines · Michal Simek
Quoted 104 lines · Heiko Schocher
Quoted 77 lines
Hello Michael,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 61 lines
U-Boot with
I2C_DMenabled 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 atff020000
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 7Thanks,
MichalChanges 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
- Usedev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus nameMichal Simek (7):
dm: core: Addof_alias_get_highest_id()
fdt: Introducefdtdec_get_alias_highest_id()
dm: core: Introducedev_read_alias_highest_id()
dm: core: Add tests fordev_read_alias_highest_id()
i2c: dm: Record maximum id of devices before probing devices
i2c: Fillreq_seqini2c_post_bind()
i2c: mux: Generate longer i2c mux nameQuoted 12 lines
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(-)Quoted 8 lines
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)drivers/i2c/i2c-uclass.c +4
-0@@ -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
Quoted 8 lines
Quoted 5 lines
drivers/i2c/i2c-uclass.c +0
-0debug ("%s: highest alias id is %d\n" , __func__, priv->max_id);SPL has no
OF_CONTROLand 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.
;-)
Quoted 9 lines
Maybe it should be enough to have dependency on
OF_LIBFDTbutKconfigis saying thatOF_LIBFDTis bool setup to y whenOF_CONTROLis enabled. And inMakefilefdtdec is enabledobj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec.o
or just
obj-$(CONFIG_OF_LIBFDT) += fdtdec.oAnyway 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
Signature · 3 lines
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
v2 cover Align U-Boot I2C DM bus ID handling with Linux
Quoted 128 lines · Heiko Schocher
Hello Michal,
Am 08.02.2019 um 12:24 schrieb Michal Simek:
Quoted 106 lines · Michal Simek
Quoted 105 lines · Heiko Schocher
Quoted 78 lines
Hello Michael,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 72 lines
U-Boot with
I2C_DMenabled 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 atff020000
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 7Thanks,
MichalChanges 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
- Usedev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus nameMichal Simek (7):
dm: core: Addof_alias_get_highest_id()
fdt: Introducefdtdec_get_alias_highest_id()
dm: core: Introducedev_read_alias_highest_id()
dm: core: Add tests fordev_read_alias_highest_id()
i2c: dm: Record maximum id of devices before probing devices
i2c: Fillreq_seqini2c_post_bind()
i2c: mux: Generate longer i2c mux namedrivers/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 ++++++++++++++++++Quoted 2 lines
9 files changed, 194 insertions(+), 6 deletions(-)Quoted 8 lines
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)drivers/i2c/i2c-uclass.c +4
-0@@ -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 Quoted 8 lines
Quoted 5 lines
drivers/i2c/i2c-uclass.c +0
-0debug("%s: highest alias id is %d\n", __func__, priv->max_id);SPL has no
OF_CONTROLand 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.;-)
Quoted 8 lines
Maybe it should be enough to have dependency on
OF_LIBFDTbutKconfigis saying thatOF_LIBFDTis bool setup to y whenOF_CONTROLis enabled. And inMakefilefdtdec is enabledobj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec.o
or just
obj-$(CONFIG_OF_LIBFDT) += fdtdec.o
Quoted 7 lines
Quoted 1 line
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
v2 cover Align U-Boot I2C DM bus ID handling with Linux
Hello Michal,
Am 11.02.2019 um 07:58 schrieb Michal Simek:
Quoted 131 lines · Heiko Schocher
Quoted 130 lines
Hello Michal,
Am 08.02.2019 um 12:24 schrieb Michal Simek:
Quoted 106 lines · Michal Simek
Quoted 105 lines · Heiko Schocher
Quoted 78 lines
Hello Michael,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 62 lines
U-Boot with
I2C_DMenabled 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 atff020000
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 7Thanks,
MichalChanges 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
- Usedev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus nameMichal Simek (7):
dm: core: Addof_alias_get_highest_id()
fdt: Introducefdtdec_get_alias_highest_id()
dm: core: Introducedev_read_alias_highest_id()
dm: core: Add tests fordev_read_alias_highest_id()
i2c: dm: Record maximum id of devices before probing devices
i2c: Fillreq_seqini2c_post_bind()
i2c: mux: Generate longer i2c mux nameQuoted 12 lines
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(-)Quoted 8 lines
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)drivers/i2c/i2c-uclass.c +4
-0@@ -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 Quoted 8 lines
Quoted 5 lines
drivers/i2c/i2c-uclass.c +0
-0debug("%s: highest alias id is %d\n", __func__, priv->max_id);SPL has no
OF_CONTROLand 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.;-)
Quoted 9 lines
Maybe it should be enough to have dependency on
OF_LIBFDTbutKconfigis saying thatOF_LIBFDTis bool setup to y whenOF_CONTROLis enabled. And inMakefilefdtdec is enabledobj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec.o
or just
obj-$(CONFIG_OF_LIBFDT) += fdtdec.oAnyway it should be likely enough to have dependency just on
OF_LIBFDT.
Quoted 7 lines
Quoted 5 lines
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
Signature · 3 lines
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
v2 cover Align U-Boot I2C DM bus ID handling with Linux
Quoted 145 lines · Heiko Schocher
Hello Michal,
Am 11.02.2019 um 07:58 schrieb Michal Simek:
Quoted 142 lines · Heiko Schocher
Quoted 141 lines
Hello Michal,
Am 08.02.2019 um 12:24 schrieb Michal Simek:
Quoted 116 lines · Michal Simek
Quoted 115 lines · Heiko Schocher
Quoted 83 lines
Hello Michael,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 77 lines
U-Boot with
I2C_DMenabled 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 atff020000
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 7Thanks,
MichalChanges 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
- Usedev_read_alias_highest_id()
- Use uclass private data
- Use private uclass data
- Fix headers
- Change patch description to focus only on bus nameMichal Simek (7):
dm: core: Addof_alias_get_highest_id()
fdt: Introducefdtdec_get_alias_highest_id()
dm: core: Introducedev_read_alias_highest_id()
dm: core: Add tests fordev_read_alias_highest_id()
i2c: dm: Record maximum id of devices before probing devices
i2c: Fillreq_seqini2c_post_bind()
i2c: mux: Generate longer i2c mux namedrivers/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 ++++++++++++++++++Quoted 2 lines
9 files changed, 194 insertions(+), 6 deletions(-)Quoted 8 lines
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)drivers/i2c/i2c-uclass.c +4
-0@@ -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);Quoted 6 lines
Quoted 3 lines
SPL has no
OF_CONTROLand 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.;-)
Quoted 10 lines
Maybe it should be enough to have dependency on
OF_LIBFDTbutKconfigis
saying thatOF_LIBFDTis bool setup to y whenOF_CONTROLis enabled. And inMakefilefdtdec is enabledobj-$(CONFIG_$(SPL_TPL_)OF_CONTROL) += fdtdec.o
or just
obj-$(CONFIG_OF_LIBFDT) += fdtdec.oAnyway it should be likely enough to have dependency just on
OF_LIBFDT.Ok, do you want to send a v3 of the patch:
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
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
PATCH v2 1/7 dm: core: Add of_alias_get_highest_id()
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 22 lines
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 stemI2C 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 <[email protected]>Acked-by Rob Herring <[email protected]>Signed-off-by Wolfram Sang <[email protected]>"
Add it also to U-Boot for DM I2C support.
Signed-off-by Michal Simek <[email protected]>---
Quoted 7 lines
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
Signature · 3 lines
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
PATCH v2 2/7 fdt: Introduce fdtdec_get_alias_highest_id()
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 4 lines
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.
Quoted 8 lines
Signed-off-by Michal Simek <[email protected]>---
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
Signature · 3 lines
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
PATCH v2 3/7 dm: core: Introduce dev_read_alias_highest_id()
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:30 schrieb Michal Simek:
Quoted 4 lines
It is wrapper for calling
of_alias_get_highest_id()when live tree is enabled andfdtdec_get_alias_highest_id()if not.Signed-off-by Michal Simek <[email protected]>
Quoted 8 lines
---
Changes in v2:
- New patchdrivers/core/read.c | 8 ++++++++ include/dm/read.h | 16 ++++++++++++++++ 2 files changed, 24 insertions(+)
Applied to u-boot-i2c.git master
Thanks!
bye,
Heiko
Signature · 3 lines
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
PATCH v2 4/7 dm: core: Add tests for dev_read_alias_highest_id()
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:31 schrieb Michal Simek:
Quoted 11 lines
It is checking the highest alias ID for eth, gpio, pci, i2c and error code on non existing alias.
Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- New patchtest/dm/test-fdt.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
Applied to u-boot-i2c.git master
Thanks!
bye,
Heiko
Signature · 3 lines
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
PATCH v2 5/7 i2c: dm: Record maximum id of devices before probing devices
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:31 schrieb Michal Simek:
Quoted 6 lines
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 <[email protected]>
Quoted 8 lines
---
Changes in v2:
- Usedev_read_alias_highest_id()
- Use uclass private datadrivers/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
Signature · 3 lines
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
PATCH v2 6/7 i2c: Fill req_seq in i2c_post_bind()
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:31 schrieb Michal Simek:
Quoted 58 lines
For i2c controllers which are missing alias in DT there is no
req_seqsetup. 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 atff020000
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 atff030000(active 1)74: i2c-mux at 74, offset len 1, flags 0 75: i2c-mux at 75, offset len 1, flags 0Bus 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 7Before this patch applied (controllers have -1 ID) ZynqMP> i2c bus
Bus 0: i2c atff020000
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 atff030000(active 1)74: i2c-mux at 74, offset len 1, flags 0 75: i2c-mux at 75, offset len 1, flags 0Bus -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
Quoted 8 lines
Signed-off-by Michal Simek <[email protected]>---
Changes in v2:
- Use private uclass datadrivers/i2c/i2c-uclass.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-)
Applied to u-boot-i2c.git master
Thanks!
bye,
Heiko
Signature · 3 lines
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
PATCH v2 7/7 i2c: mux: Generate longer i2c mux name
In reply to Michal SimekHello Michal,
Am 31.01.2019 um 16:31 schrieb Michal Simek:
Quoted 85 lines
For !DM case busses are listed as
ZynqMP> i2c bus
Bus 0:zynq_0
Bus 1:zynq_0->PCA9544Aat 0x75:0
Bus 2:zynq_0->PCA9544Aat 0x75:1
Bus 3:zynq_0->PCA9544Aat 0x75:2
Bus 4:zynq_1
Bus 5:zynq_1->PCA9548at 0x74:0
Bus 6:zynq_1->PCA9548at 0x74:1
Bus 7:zynq_1->PCA9548at 0x74:2
Bus 8:zynq_1->PCA9548at 0x74:3
Bus 9:zynq_1->PCA9548at 0x74:4
Bus 10:zynq_1->PCA9548at 0x75:0
Bus 11:zynq_1->PCA9548at 0x75:1
Bus 12:zynq_1->PCA9548at 0x75:2
Bus 13:zynq_1->PCA9548at 0x75:3
Bus 14:zynq_1->PCA9548at 0x75:4
Bus 15:zynq_1->PCA9548at 0x75:5
Bus 16:zynq_1->PCA9548at 0x75:6
Bus 17:zynq_1->PCA9548at 0x75:7where 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 atff020000
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 atff030000(active 1)74: i2c-mux at 74, offset len 1, flags 0 75: i2c-mux at 75, offset len 1, flags 0Bus 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 7Behavior before the patch is applied.
ZynqMP> i2c bus
Bus 0: i2c atff020000
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 atff030000(active 1)74: i2c-mux at 74, offset len 1, flags 0 75: i2c-mux at 75, offset len 1, flags 0Bus 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 7Signed-off-by Michal Simek <[email protected]>
Quoted 8 lines
---
Changes in v2:
- Fix headers
- Change patch description to focus only on bus namedrivers/i2c/muxes/i2c-mux-uclass.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
Applied to u-boot-i2c.git master
Thanks!
bye,
Heiko
Signature · 3 lines
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