From: Simon Glass Date: Thu, 17 Dec 2020 04:20:15 +0000 (-0700) Subject: i2c: Update for new sequence numbers X-Git-Url: http://git.dujemihanovic.xyz/?a=commitdiff_plain;h=16df99324663fd3f88cb5e1ce241ee3f9f9ddacd;p=u-boot.git i2c: Update for new sequence numbers Use the new sequence number in all cases. Drop the logic to check for a valid number in designware_i2c, since it will always be valid. Also drop the numbering in the uclass, since we can rely on driver model giving us the right sequence numbers. Signed-off-by: Simon Glass --- diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c index 3c15320674..18eef625f0 100644 --- a/drivers/i2c/designware_i2c_pci.c +++ b/drivers/i2c/designware_i2c_pci.c @@ -90,32 +90,12 @@ static int designware_i2c_pci_probe(struct udevice *dev) static int designware_i2c_pci_bind(struct udevice *dev) { - struct uclass *uc; char name[20]; - int ret; if (dev_of_valid(dev)) return 0; - /* - * Create a unique device name for PCI type devices - * ToDo: - * Setting req_seq in the driver is probably not recommended. - * But without a DT alias the number is not configured. And - * using this driver is impossible for PCIe I2C devices. - * This can be removed, once a better (correct) way for this - * is found and implemented. - * - * TODO(sjg@chromium.org): Perhaps if uclasses had platdata this would - * be possible. We cannot use static data in drivers since they may be - * used in SPL or before relocation. - */ - ret = uclass_get(UCLASS_I2C, &uc); - if (ret) - return ret; - - dev->req_seq = uclass_find_next_free_req_seq(uc); - sprintf(name, "i2c_designware#%u", dev->req_seq); + sprintf(name, "i2c_designware#%u", dev_seq(dev)); device_set_name(dev, name); return 0; diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index 490437bd42..456cf3b85f 100644 --- a/drivers/i2c/i2c-uclass.c +++ b/drivers/i2c/i2c-uclass.c @@ -686,27 +686,11 @@ static int i2c_child_post_bind(struct udevice *dev) #endif } -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); + debug("%s: %s, seq=%d\n", __func__, dev->name, dev_seq(dev)); #if CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA) ret = dm_scan_fdt_dev(dev); @@ -714,32 +698,11 @@ static int i2c_post_bind(struct udevice *dev) return ret; } -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. */ - if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) - priv->max_id = dev_read_alias_highest_id("i2c"); - else - priv->max_id = -1; - - debug("%s: highest alias id is %d\n", __func__, priv->max_id); - - return 0; -} - UCLASS_DRIVER(i2c) = { .id = UCLASS_I2C, .name = "i2c", .flags = DM_UC_FLAG_SEQ_ALIAS, .post_bind = i2c_post_bind, - .init = i2c_uclass_init, - .priv_auto = sizeof(struct i2c_priv), .pre_probe = i2c_pre_probe, .post_probe = i2c_post_probe, .per_device_auto = sizeof(struct dm_i2c_bus), diff --git a/drivers/i2c/i2c-versatile.c b/drivers/i2c/i2c-versatile.c index 8183202d31..0a1a85dfc2 100644 --- a/drivers/i2c/i2c-versatile.c +++ b/drivers/i2c/i2c-versatile.c @@ -252,11 +252,6 @@ static int versatile_i2c_probe(struct udevice *dev) priv->base = (phys_addr_t)dev_read_addr(dev); priv->delay = 25; /* 25us * 4 = 100kHz */ - /* - * U-Boot still doesn't assign automatically - * sequence numbers to devices - */ - dev->req_seq = 1; return 0; } diff --git a/drivers/i2c/intel_i2c.c b/drivers/i2c/intel_i2c.c index c92074a619..52f7a528ef 100644 --- a/drivers/i2c/intel_i2c.c +++ b/drivers/i2c/intel_i2c.c @@ -269,21 +269,11 @@ static int intel_i2c_probe(struct udevice *dev) static int intel_i2c_bind(struct udevice *dev) { - static int num_cards __attribute__ ((section(".data"))); char name[20]; /* Create a unique device name for PCI type devices */ if (device_is_on_pci_bus(dev)) { - /* - * ToDo: - * Setting req_seq in the driver is probably not recommended. - * But without a DT alias the number is not configured. And - * using this driver is impossible for PCIe I2C devices. - * This can be removed, once a better (correct) way for this - * is found and implemented. - */ - dev->req_seq = num_cards; - sprintf(name, "intel_i2c#%u", num_cards++); + sprintf(name, "intel_i2c#%u", dev_seq(dev)); device_set_name(dev, name); } diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c index d69c12001c..dbca409ee3 100644 --- a/drivers/i2c/muxes/i2c-mux-uclass.c +++ b/drivers/i2c/muxes/i2c-mux-uclass.c @@ -87,8 +87,8 @@ static int i2c_mux_post_bind(struct udevice *mux) 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); + debug(" - bind ret=%d, %s, seq %d\n", ret, + dev ? dev->name : NULL, dev_seq(dev)); if (ret) return ret; } diff --git a/drivers/i2c/mvtwsi.c b/drivers/i2c/mvtwsi.c index 1fcb8c698b..a4d59b67a2 100644 --- a/drivers/i2c/mvtwsi.c +++ b/drivers/i2c/mvtwsi.c @@ -823,9 +823,9 @@ static int mvtwsi_i2c_bind(struct udevice *bus) struct mvtwsi_registers *twsi = dev_read_addr_ptr(bus); /* Disable the hidden slave in i2c0 of these platforms */ - if ((IS_ENABLED(CONFIG_ARMADA_38X) || IS_ENABLED(CONFIG_ARCH_KIRKWOOD) - || IS_ENABLED(CONFIG_ARMADA_8K)) - && bus->req_seq == 0) + if ((IS_ENABLED(CONFIG_ARMADA_38X) || + IS_ENABLED(CONFIG_ARCH_KIRKWOOD) || + IS_ENABLED(CONFIG_ARMADA_8K)) && !dev_seq(bus)) twsi_disable_i2c_slave(twsi); return 0;