diff options
Diffstat (limited to 'drivers/i2c')
-rw-r--r-- | drivers/i2c/ast_i2c.c | 4 | ||||
-rw-r--r-- | drivers/i2c/davinci_i2c.c | 2 | ||||
-rw-r--r-- | drivers/i2c/designware_i2c_pci.c | 16 | ||||
-rw-r--r-- | drivers/i2c/exynos_hs_i2c.c | 2 | ||||
-rw-r--r-- | drivers/i2c/i2c-gpio.c | 2 | ||||
-rw-r--r-- | drivers/i2c/i2c-uclass.c | 39 | ||||
-rw-r--r-- | drivers/i2c/i2c-versatile.c | 5 | ||||
-rw-r--r-- | drivers/i2c/imx_lpi2c.c | 12 | ||||
-rw-r--r-- | drivers/i2c/intel_i2c.c | 12 | ||||
-rw-r--r-- | drivers/i2c/lpc32xx_i2c.c | 6 | ||||
-rw-r--r-- | drivers/i2c/muxes/i2c-mux-uclass.c | 4 | ||||
-rw-r--r-- | drivers/i2c/mvtwsi.c | 6 | ||||
-rw-r--r-- | drivers/i2c/mxc_i2c.c | 10 | ||||
-rw-r--r-- | drivers/i2c/nx_i2c.c | 2 | ||||
-rw-r--r-- | drivers/i2c/octeon_i2c.c | 3 | ||||
-rw-r--r-- | drivers/i2c/s3c24x0_i2c.c | 2 | ||||
-rw-r--r-- | drivers/i2c/tegra_i2c.c | 5 |
17 files changed, 35 insertions, 97 deletions
diff --git a/drivers/i2c/ast_i2c.c b/drivers/i2c/ast_i2c.c index 3aa8ad1..2d3feca 100644 --- a/drivers/i2c/ast_i2c.c +++ b/drivers/i2c/ast_i2c.c @@ -110,7 +110,7 @@ static int ast_i2c_probe(struct udevice *dev) { struct ast2500_scu *scu; - debug("Enabling I2C%u\n", dev->seq); + debug("Enabling I2C%u\n", dev_seq(dev)); /* * Get all I2C devices out of Reset. @@ -307,7 +307,7 @@ static int ast_i2c_set_speed(struct udevice *dev, unsigned int speed) struct ast_i2c_regs *regs = priv->regs; ulong i2c_rate, divider; - debug("Setting speed for I2C%d to <%u>\n", dev->seq, speed); + debug("Setting speed for I2C%d to <%u>\n", dev_seq(dev), speed); if (!speed) { debug("No valid speed specified\n"); return -EINVAL; diff --git a/drivers/i2c/davinci_i2c.c b/drivers/i2c/davinci_i2c.c index 074d609..7811aba 100644 --- a/drivers/i2c/davinci_i2c.c +++ b/drivers/i2c/davinci_i2c.c @@ -470,7 +470,7 @@ static int davinci_i2c_probe(struct udevice *dev) { struct i2c_bus *i2c_bus = dev_get_priv(dev); - i2c_bus->id = dev->seq; + i2c_bus->id = dev_seq(dev); i2c_bus->regs = dev_read_addr_ptr(dev); i2c_bus->speed = 100000; diff --git a/drivers/i2c/designware_i2c_pci.c b/drivers/i2c/designware_i2c_pci.c index 8d7b1fe..18eef62 100644 --- a/drivers/i2c/designware_i2c_pci.c +++ b/drivers/i2c/designware_i2c_pci.c @@ -95,21 +95,7 @@ static int designware_i2c_pci_bind(struct udevice *dev) 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. - */ - dev->req_seq = uclass_find_next_free_req_seq(UCLASS_I2C); - 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/exynos_hs_i2c.c b/drivers/i2c/exynos_hs_i2c.c index 7dbf0a4..879ddc6 100644 --- a/drivers/i2c/exynos_hs_i2c.c +++ b/drivers/i2c/exynos_hs_i2c.c @@ -533,7 +533,7 @@ static int s3c_i2c_of_to_plat(struct udevice *dev) dev_read_u32_default(dev, "clock-frequency", I2C_SPEED_STANDARD_RATE); i2c_bus->node = node; - i2c_bus->bus_num = dev->seq; + i2c_bus->bus_num = dev_seq(dev); exynos_pinmux_config(i2c_bus->id, PINMUX_FLAG_HS_MODE); diff --git a/drivers/i2c/i2c-gpio.c b/drivers/i2c/i2c-gpio.c index 8bd96a0..387f00b 100644 --- a/drivers/i2c/i2c-gpio.c +++ b/drivers/i2c/i2c-gpio.c @@ -298,7 +298,7 @@ static int i2c_gpio_probe(struct udevice *dev, uint chip, uint chip_flags) i2c_gpio_send_stop(bus, delay); debug("%s: bus: %d (%s) chip: %x flags: %x ret: %d\n", - __func__, dev->seq, dev->name, chip, chip_flags, ret); + __func__, dev_seq(dev), dev->name, chip, chip_flags, ret); return ret; } diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c index 490437b..456cf3b 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 8183202..0a1a85d 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/imx_lpi2c.c b/drivers/i2c/imx_lpi2c.c index 270a494..92c5003 100644 --- a/drivers/i2c/imx_lpi2c.c +++ b/drivers/i2c/imx_lpi2c.c @@ -289,7 +289,7 @@ static int bus_i2c_set_bus_speed(struct udevice *bus, int speed) return clock_rate; } } else { - clock_rate = imx_get_i2cclk(bus->seq); + clock_rate = imx_get_i2cclk(dev_seq(bus)); if (!clock_rate) return -EPERM; } @@ -377,7 +377,7 @@ static int bus_i2c_init(struct udevice *bus, int speed) val = readl(®s->mcr) & ~LPI2C_MCR_MEN_MASK; writel(val | LPI2C_MCR_MEN(1), ®s->mcr); - debug("i2c : controller bus %d, speed %d:\n", bus->seq, speed); + debug("i2c : controller bus %d, speed %d:\n", dev_seq(bus), speed); return ret; } @@ -452,11 +452,11 @@ static int imx_lpi2c_probe(struct udevice *bus) return -EINVAL; i2c_bus->base = addr; - i2c_bus->index = bus->seq; + i2c_bus->index = dev_seq(bus); i2c_bus->bus = bus; /* power up i2c resource */ - ret = init_i2c_power(bus->seq); + ret = init_i2c_power(dev_seq(bus)); if (ret) { debug("init_i2c_power err = %d\n", ret); return ret; @@ -486,7 +486,7 @@ static int imx_lpi2c_probe(struct udevice *bus) } } else { /* To i.MX7ULP, only i2c4-7 can be handled by A7 core */ - ret = enable_i2c_clk(1, bus->seq); + ret = enable_i2c_clk(1, dev_seq(bus)); if (ret < 0) return ret; } @@ -496,7 +496,7 @@ static int imx_lpi2c_probe(struct udevice *bus) return ret; debug("i2c : controller bus %d at 0x%lx , speed %d: ", - bus->seq, i2c_bus->base, + dev_seq(bus), i2c_bus->base, i2c_bus->speed); return 0; diff --git a/drivers/i2c/intel_i2c.c b/drivers/i2c/intel_i2c.c index c92074a..52f7a52 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/lpc32xx_i2c.c b/drivers/i2c/lpc32xx_i2c.c index e321d4b..ad11e97 100644 --- a/drivers/i2c/lpc32xx_i2c.c +++ b/drivers/i2c/lpc32xx_i2c.c @@ -282,7 +282,11 @@ U_BOOT_I2C_ADAP_COMPLETE(lpc32xx_2, lpc32xx_i2c_init, NULL, static int lpc32xx_i2c_probe(struct udevice *bus) { struct lpc32xx_i2c_dev *dev = dev_get_plat(bus); - bus->seq = dev->index; + + /* + * FIXME: This is not permitted + * dev_seq(bus) = dev->index; + */ __i2c_init(dev->base, dev->speed, 0, dev->index); return 0; diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c index d69c120..dbca409 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 1fcb8c6..a4d59b6 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; diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c index 3d37858..cbc2bbf 100644 --- a/drivers/i2c/mxc_i2c.c +++ b/drivers/i2c/mxc_i2c.c @@ -914,7 +914,7 @@ static int mxc_i2c_probe(struct udevice *bus) } i2c_bus->base = addr; - i2c_bus->index = bus->seq; + i2c_bus->index = dev_seq(bus); i2c_bus->bus = bus; /* Enable clk */ @@ -930,7 +930,7 @@ static int mxc_i2c_probe(struct udevice *bus) return ret; } #else - ret = enable_i2c_clk(1, bus->seq); + ret = enable_i2c_clk(1, dev_seq(bus)); if (ret < 0) return ret; #endif @@ -942,7 +942,7 @@ static int mxc_i2c_probe(struct udevice *bus) ret = fdt_stringlist_search(fdt, node, "pinctrl-names", "gpio"); if (ret < 0) { debug("i2c bus %d at 0x%2lx, no gpio pinctrl state.\n", - bus->seq, i2c_bus->base); + dev_seq(bus), i2c_bus->base); } else { ret = gpio_request_by_name_nodev(offset_to_ofnode(node), "scl-gpios", 0, &i2c_bus->scl_gpio, @@ -955,7 +955,7 @@ static int mxc_i2c_probe(struct udevice *bus) ret || ret2) { dev_err(bus, "i2c bus %d at %lu, fail to request scl/sda gpio\n", - bus->seq, i2c_bus->base); + dev_seq(bus), i2c_bus->base); return -EINVAL; } } @@ -966,7 +966,7 @@ static int mxc_i2c_probe(struct udevice *bus) */ debug("i2c : controller bus %d at %lu , speed %d: ", - bus->seq, i2c_bus->base, + dev_seq(bus), i2c_bus->base, i2c_bus->speed); return 0; diff --git a/drivers/i2c/nx_i2c.c b/drivers/i2c/nx_i2c.c index a672c01..c63a732 100644 --- a/drivers/i2c/nx_i2c.c +++ b/drivers/i2c/nx_i2c.c @@ -240,7 +240,7 @@ static int nx_i2c_probe(struct udevice *dev) return -EINVAL; bus->regs = (struct nx_i2c_regs *)addr; - bus->bus_num = dev->seq; + bus->bus_num = dev_seq(dev); /* i2c node parsing */ i2c_process_node(dev); diff --git a/drivers/i2c/octeon_i2c.c b/drivers/i2c/octeon_i2c.c index b1a9cce..ea2cc33 100644 --- a/drivers/i2c/octeon_i2c.c +++ b/drivers/i2c/octeon_i2c.c @@ -791,7 +791,6 @@ static int octeon_i2c_probe(struct udevice *dev) pci_dev_t bdf = dm_pci_get_bdf(dev); debug("TWSI PCI device: %x\n", bdf); - dev->req_seq = PCI_FUNC(bdf); twsi->base = dm_pci_map_bar(dev, PCI_BASE_ADDRESS_0, PCI_REGION_MEM); @@ -811,7 +810,7 @@ static int octeon_i2c_probe(struct udevice *dev) if (ret) return ret; - debug("TWSI bus %d at %p\n", dev->seq, twsi->base); + debug("TWSI bus %d at %p\n", dev_seq(dev), twsi->base); /* Start with standard speed, real speed set via DT or cmd */ return twsi_init(twsi->base, i2c_slave_addr); diff --git a/drivers/i2c/s3c24x0_i2c.c b/drivers/i2c/s3c24x0_i2c.c index ff2c345..0c89156 100644 --- a/drivers/i2c/s3c24x0_i2c.c +++ b/drivers/i2c/s3c24x0_i2c.c @@ -318,7 +318,7 @@ static int s3c_i2c_of_to_plat(struct udevice *dev) dev_read_u32_default(dev, "clock-frequency", I2C_SPEED_STANDARD_RATE); i2c_bus->node = node; - i2c_bus->bus_num = dev->seq; + i2c_bus->bus_num = dev_seq(dev); exynos_pinmux_config(i2c_bus->id, 0); diff --git a/drivers/i2c/tegra_i2c.c b/drivers/i2c/tegra_i2c.c index 7cb5e8b..1e74484 100644 --- a/drivers/i2c/tegra_i2c.c +++ b/drivers/i2c/tegra_i2c.c @@ -362,7 +362,7 @@ static int tegra_i2c_probe(struct udevice *dev) int ret; bool is_dvc; - i2c_bus->id = dev->seq; + i2c_bus->id = dev_seq(dev); i2c_bus->type = dev_get_driver_data(dev); i2c_bus->regs = (struct i2c_ctlr *)dev_read_addr(dev); if ((ulong)i2c_bus->regs == FDT_ADDR_T_NONE) { @@ -408,7 +408,8 @@ static int tegra_i2c_probe(struct udevice *dev) } i2c_init_controller(i2c_bus); debug("%s: controller bus %d at %p, speed %d: ", - is_dvc ? "dvc" : "i2c", dev->seq, i2c_bus->regs, i2c_bus->speed); + is_dvc ? "dvc" : "i2c", dev_seq(dev), i2c_bus->regs, + i2c_bus->speed); return 0; } |