Lines Matching +full:ocelot +full:- +full:i2c

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Synopsys DesignWare I2C adapter driver.
5 * Based on the TI DAVINCI I2C adapter driver.
11 #include <linux/clk-provider.h>
17 #include <linux/i2c.h>
33 #include "i2c-designware-core.h"
37 return clk_get_rate(dev->clk) / KILO; in i2c_dw_get_clk_rate_khz()
57 ret = regmap_write(dev->sysmap, BT1_I2C_CTL, in bt1_i2c_read()
62 return regmap_read(dev->sysmap, BT1_I2C_DO, val); in bt1_i2c_read()
70 ret = regmap_write(dev->sysmap, BT1_I2C_DI, val); in bt1_i2c_write()
74 return regmap_write(dev->sysmap, BT1_I2C_CTL, in bt1_i2c_write()
90 dev->sysmap = syscon_node_to_regmap(dev->dev->of_node->parent); in bt1_i2c_request_regs()
91 if (IS_ERR(dev->sysmap)) in bt1_i2c_request_regs()
92 return PTR_ERR(dev->sysmap); in bt1_i2c_request_regs()
94 dev->map = devm_regmap_init(dev->dev, NULL, dev, &bt1_i2c_cfg); in bt1_i2c_request_regs()
95 return PTR_ERR_OR_ZERO(dev->map); in bt1_i2c_request_regs()
100 return -ENODEV; in bt1_i2c_request_regs()
106 dev->map = dev_get_regmap(dev->dev->parent, NULL); in txgbe_i2c_request_regs()
107 if (!dev->map) in txgbe_i2c_request_regs()
108 return -ENODEV; in txgbe_i2c_request_regs()
115 pm_runtime_disable(dev->dev); in dw_i2c_plat_pm_cleanup()
117 if (dev->shared_with_punit) in dw_i2c_plat_pm_cleanup()
118 pm_runtime_put_noidle(dev->dev); in dw_i2c_plat_pm_cleanup()
123 struct platform_device *pdev = to_platform_device(dev->dev); in dw_i2c_plat_request_regs()
126 switch (dev->flags & MODEL_MASK) { in dw_i2c_plat_request_regs()
134 dev->base = devm_platform_ioremap_resource(pdev, 0); in dw_i2c_plat_request_regs()
135 ret = PTR_ERR_OR_ZERO(dev->base); in dw_i2c_plat_request_regs()
173 dev->semaphore_idx = -1; in i2c_dw_probe_lock_support()
175 for (ptr = i2c_dw_semaphore_cb_table; ptr->probe; ptr++) { in i2c_dw_probe_lock_support()
176 ret = ptr->probe(dev); in i2c_dw_probe_lock_support()
183 if (ret != -ENODEV) in i2c_dw_probe_lock_support()
190 dev->semaphore_idx = i; in i2c_dw_probe_lock_support()
199 if (dev->semaphore_idx < 0) in i2c_dw_remove_lock_support()
202 if (i2c_dw_semaphore_cb_table[dev->semaphore_idx].remove) in i2c_dw_remove_lock_support()
203 i2c_dw_semaphore_cb_table[dev->semaphore_idx].remove(dev); in i2c_dw_remove_lock_support()
208 struct device *device = &pdev->dev; in dw_i2c_plat_probe()
219 return -ENOMEM; in dw_i2c_plat_probe()
221 dev->flags = (uintptr_t)device_get_match_data(device); in dw_i2c_plat_probe()
222 if (device_property_present(device, "wx,i2c-snps-model")) in dw_i2c_plat_probe()
223 dev->flags = MODEL_WANGXUN_SP | ACCESS_POLLING; in dw_i2c_plat_probe()
225 dev->dev = device; in dw_i2c_plat_probe()
226 dev->irq = irq; in dw_i2c_plat_probe()
233 dev->rst = devm_reset_control_get_optional_exclusive(device, NULL); in dw_i2c_plat_probe()
234 if (IS_ERR(dev->rst)) in dw_i2c_plat_probe()
235 return PTR_ERR(dev->rst); in dw_i2c_plat_probe()
237 reset_control_deassert(dev->rst); in dw_i2c_plat_probe()
250 dev->pclk = devm_clk_get_optional(device, "pclk"); in dw_i2c_plat_probe()
251 if (IS_ERR(dev->pclk)) { in dw_i2c_plat_probe()
252 ret = PTR_ERR(dev->pclk); in dw_i2c_plat_probe()
256 dev->clk = devm_clk_get_optional(device, NULL); in dw_i2c_plat_probe()
257 if (IS_ERR(dev->clk)) { in dw_i2c_plat_probe()
258 ret = PTR_ERR(dev->clk); in dw_i2c_plat_probe()
266 if (dev->clk) { in dw_i2c_plat_probe()
267 struct i2c_timings *t = &dev->timings; in dw_i2c_plat_probe()
270 dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; in dw_i2c_plat_probe()
271 clk_khz = dev->get_clk_rate_khz(dev); in dw_i2c_plat_probe()
273 if (!dev->sda_hold_time && t->sda_hold_ns) in dw_i2c_plat_probe()
274 dev->sda_hold_time = in dw_i2c_plat_probe()
275 DIV_S64_ROUND_CLOSEST(clk_khz * t->sda_hold_ns, MICRO); in dw_i2c_plat_probe()
278 adap = &dev->adapter; in dw_i2c_plat_probe()
279 adap->owner = THIS_MODULE; in dw_i2c_plat_probe()
280 adap->class = dmi_check_system(dw_i2c_hwmon_class_dmi) ? in dw_i2c_plat_probe()
282 adap->nr = -1; in dw_i2c_plat_probe()
284 if (dev->flags & ACCESS_NO_IRQ_SUSPEND) in dw_i2c_plat_probe()
298 if (dev->shared_with_punit) in dw_i2c_plat_probe()
312 reset_control_assert(dev->rst); in dw_i2c_plat_probe()
319 struct device *device = &pdev->dev; in dw_i2c_plat_remove()
323 i2c_del_adapter(&dev->adapter); in dw_i2c_plat_remove()
333 reset_control_assert(dev->rst); in dw_i2c_plat_remove()
337 { .compatible = "snps,designware-i2c", },
338 { .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT },
339 { .compatible = "baikal,bt1-sys-i2c", .data = (void *)MODEL_BAIKAL_BT1 },
398 MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter");