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.
12 #include <linux/clk-provider.h>
18 #include <linux/i2c.h>
25 #include <linux/platform_data/i2c-designware.h>
36 #include "i2c-designware-core.h"
40 return clk_get_rate(dev->clk)/1000; in i2c_dw_get_clk_rate_khz()
81 ret = regmap_write(dev->sysmap, BT1_I2C_CTL, in bt1_i2c_read()
86 return regmap_read(dev->sysmap, BT1_I2C_DO, val); in bt1_i2c_read()
94 ret = regmap_write(dev->sysmap, BT1_I2C_DI, val); in bt1_i2c_write()
98 return regmap_write(dev->sysmap, BT1_I2C_CTL, in bt1_i2c_write()
114 dev->sysmap = syscon_node_to_regmap(dev->dev->of_node->parent); in bt1_i2c_request_regs()
115 if (IS_ERR(dev->sysmap)) in bt1_i2c_request_regs()
116 return PTR_ERR(dev->sysmap); in bt1_i2c_request_regs()
118 dev->map = devm_regmap_init(dev->dev, NULL, dev, &bt1_i2c_cfg); in bt1_i2c_request_regs()
119 return PTR_ERR_OR_ZERO(dev->map); in bt1_i2c_request_regs()
128 writel((dev->sda_hold_time << 1) | MSCC_ICPU_CFG_TWI_DELAY_ENABLE, in mscc_twi_set_sda_hold_time()
129 dev->ext + MSCC_ICPU_CFG_TWI_DELAY); in mscc_twi_set_sda_hold_time()
138 switch (dev->flags & MODEL_MASK) { in dw_i2c_of_configure()
140 dev->ext = devm_platform_ioremap_resource(pdev, 1); in dw_i2c_of_configure()
141 if (!IS_ERR(dev->ext)) in dw_i2c_of_configure()
142 dev->set_sda_hold_time = mscc_twi_set_sda_hold_time; in dw_i2c_of_configure()
152 { .compatible = "snps,designware-i2c", },
153 { .compatible = "mscc,ocelot-i2c", .data = (void *)MODEL_MSCC_OCELOT },
154 { .compatible = "baikal,bt1-sys-i2c", .data = (void *)MODEL_BAIKAL_BT1 },
161 return -ENODEV; in bt1_i2c_request_regs()
166 return -ENODEV; in dw_i2c_of_configure()
172 pm_runtime_disable(dev->dev); in dw_i2c_plat_pm_cleanup()
174 if (dev->shared_with_punit) in dw_i2c_plat_pm_cleanup()
175 pm_runtime_put_noidle(dev->dev); in dw_i2c_plat_pm_cleanup()
180 struct platform_device *pdev = to_platform_device(dev->dev); in dw_i2c_plat_request_regs()
183 switch (dev->flags & MODEL_MASK) { in dw_i2c_plat_request_regs()
188 dev->base = devm_platform_ioremap_resource(pdev, 0); in dw_i2c_plat_request_regs()
189 ret = PTR_ERR_OR_ZERO(dev->base); in dw_i2c_plat_request_regs()
209 struct dw_i2c_platform_data *pdata = dev_get_platdata(&pdev->dev); in dw_i2c_plat_probe()
219 dev = devm_kzalloc(&pdev->dev, sizeof(struct dw_i2c_dev), GFP_KERNEL); in dw_i2c_plat_probe()
221 return -ENOMEM; in dw_i2c_plat_probe()
223 dev->flags = (uintptr_t)device_get_match_data(&pdev->dev); in dw_i2c_plat_probe()
224 dev->dev = &pdev->dev; in dw_i2c_plat_probe()
225 dev->irq = irq; in dw_i2c_plat_probe()
232 dev->rst = devm_reset_control_get_optional_exclusive(&pdev->dev, NULL); in dw_i2c_plat_probe()
233 if (IS_ERR(dev->rst)) in dw_i2c_plat_probe()
234 return PTR_ERR(dev->rst); in dw_i2c_plat_probe()
236 reset_control_deassert(dev->rst); in dw_i2c_plat_probe()
238 t = &dev->timings; in dw_i2c_plat_probe()
240 t->bus_freq_hz = pdata->i2c_scl_freq; in dw_i2c_plat_probe()
242 i2c_parse_fw_timings(&pdev->dev, t, false); in dw_i2c_plat_probe()
246 if (pdev->dev.of_node) in dw_i2c_plat_probe()
249 if (has_acpi_companion(&pdev->dev)) in dw_i2c_plat_probe()
250 i2c_dw_acpi_configure(&pdev->dev); in dw_i2c_plat_probe()
263 dev->pclk = devm_clk_get_optional(&pdev->dev, "pclk"); in dw_i2c_plat_probe()
264 if (IS_ERR(dev->pclk)) { in dw_i2c_plat_probe()
265 ret = PTR_ERR(dev->pclk); in dw_i2c_plat_probe()
269 dev->clk = devm_clk_get(&pdev->dev, NULL); in dw_i2c_plat_probe()
273 dev->get_clk_rate_khz = i2c_dw_get_clk_rate_khz; in dw_i2c_plat_probe()
274 clk_khz = dev->get_clk_rate_khz(dev); in dw_i2c_plat_probe()
276 if (!dev->sda_hold_time && t->sda_hold_ns) in dw_i2c_plat_probe()
277 dev->sda_hold_time = in dw_i2c_plat_probe()
278 div_u64(clk_khz * t->sda_hold_ns + 500000, 1000000); in dw_i2c_plat_probe()
281 adap = &dev->adapter; in dw_i2c_plat_probe()
282 adap->owner = THIS_MODULE; in dw_i2c_plat_probe()
283 adap->class = dmi_check_system(dw_i2c_hwmon_class_dmi) ? in dw_i2c_plat_probe()
285 ACPI_COMPANION_SET(&adap->dev, ACPI_COMPANION(&pdev->dev)); in dw_i2c_plat_probe()
286 adap->dev.of_node = pdev->dev.of_node; in dw_i2c_plat_probe()
287 adap->nr = -1; in dw_i2c_plat_probe()
289 if (dev->flags & ACCESS_NO_IRQ_SUSPEND) { in dw_i2c_plat_probe()
290 dev_pm_set_driver_flags(&pdev->dev, in dw_i2c_plat_probe()
294 dev_pm_set_driver_flags(&pdev->dev, in dw_i2c_plat_probe()
301 WARN_ON(pm_runtime_enabled(&pdev->dev)); in dw_i2c_plat_probe()
303 pm_runtime_set_autosuspend_delay(&pdev->dev, 1000); in dw_i2c_plat_probe()
304 pm_runtime_use_autosuspend(&pdev->dev); in dw_i2c_plat_probe()
305 pm_runtime_set_active(&pdev->dev); in dw_i2c_plat_probe()
307 if (dev->shared_with_punit) in dw_i2c_plat_probe()
308 pm_runtime_get_noresume(&pdev->dev); in dw_i2c_plat_probe()
310 pm_runtime_enable(&pdev->dev); in dw_i2c_plat_probe()
321 reset_control_assert(dev->rst); in dw_i2c_plat_probe()
329 pm_runtime_get_sync(&pdev->dev); in dw_i2c_plat_remove()
331 i2c_del_adapter(&dev->adapter); in dw_i2c_plat_remove()
333 dev->disable(dev); in dw_i2c_plat_remove()
335 pm_runtime_dont_use_autosuspend(&pdev->dev); in dw_i2c_plat_remove()
336 pm_runtime_put_sync(&pdev->dev); in dw_i2c_plat_remove()
339 reset_control_assert(dev->rst); in dw_i2c_plat_remove()
349 * may be accessed during suspend and resume of other devices via I2C in dw_i2c_plat_prepare()
377 i_dev->suspended = true; in dw_i2c_plat_suspend()
379 if (i_dev->shared_with_punit) in dw_i2c_plat_suspend()
382 i_dev->disable(i_dev); in dw_i2c_plat_suspend()
392 if (!i_dev->shared_with_punit) in dw_i2c_plat_resume()
395 i_dev->init(i_dev); in dw_i2c_plat_resume()
396 i_dev->suspended = false; in dw_i2c_plat_resume()
440 MODULE_DESCRIPTION("Synopsys DesignWare I2C bus adapter");