Lines Matching +full:sama5d2 +full:- +full:i2c

1 // SPDX-License-Identifier: GPL-2.0
3 * i2c Support for Atmel's AT91 Two-Wire Interface (TWI)
18 #include <linux/i2c.h>
26 #include "i2c-at91.h"
30 return readl_relaxed(dev->base + reg); in at91_twi_read()
35 writel_relaxed(val, dev->base + reg); in at91_twi_write()
45 dev->imr = at91_twi_read(dev, AT91_TWI_IMR) & AT91_TWI_INT_MASK; in at91_twi_irq_save()
51 at91_twi_write(dev, AT91_TWI_IER, dev->imr); in at91_twi_irq_restore()
58 if (dev->slave_detected) in at91_init_twi_bus()
92 .name = "i2c-at91rm9200",
95 .name = "i2c-at91sam9261",
98 .name = "i2c-at91sam9260",
101 .name = "i2c-at91sam9g20",
104 .name = "i2c-at91sam9g10",
150 .compatible = "atmel,at91rm9200-i2c",
153 .compatible = "atmel,at91sam9260-i2c",
156 .compatible = "atmel,at91sam9261-i2c",
159 .compatible = "atmel,at91sam9g20-i2c",
162 .compatible = "atmel,at91sam9g10-i2c",
165 .compatible = "atmel,at91sam9x5-i2c",
168 .compatible = "atmel,sama5d4-i2c",
171 .compatible = "atmel,sama5d2-i2c",
174 .compatible = "microchip,sam9x60-i2c",
186 if (pdev->dev.of_node) { in at91_twi_get_driver_data()
188 match = of_match_node(atmel_twi_dt_ids, pdev->dev.of_node); in at91_twi_get_driver_data()
191 return (struct at91_twi_pdata *)match->data; in at91_twi_get_driver_data()
193 return (struct at91_twi_pdata *) platform_get_device_id(pdev)->driver_data; in at91_twi_get_driver_data()
203 dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL); in at91_twi_probe()
205 return -ENOMEM; in at91_twi_probe()
207 dev->dev = &pdev->dev; in at91_twi_probe()
209 dev->base = devm_platform_get_and_ioremap_resource(pdev, 0, &mem); in at91_twi_probe()
210 if (IS_ERR(dev->base)) in at91_twi_probe()
211 return PTR_ERR(dev->base); in at91_twi_probe()
212 phy_addr = mem->start; in at91_twi_probe()
214 dev->pdata = at91_twi_get_driver_data(pdev); in at91_twi_probe()
215 if (!dev->pdata) in at91_twi_probe()
216 return -ENODEV; in at91_twi_probe()
218 dev->irq = platform_get_irq(pdev, 0); in at91_twi_probe()
219 if (dev->irq < 0) in at91_twi_probe()
220 return dev->irq; in at91_twi_probe()
224 dev->clk = devm_clk_get(dev->dev, NULL); in at91_twi_probe()
225 if (IS_ERR(dev->clk)) in at91_twi_probe()
226 return dev_err_probe(dev->dev, PTR_ERR(dev->clk), "no clock defined\n"); in at91_twi_probe()
228 clk_prepare_enable(dev->clk); in at91_twi_probe()
230 snprintf(dev->adapter.name, sizeof(dev->adapter.name), "AT91"); in at91_twi_probe()
231 i2c_set_adapdata(&dev->adapter, dev); in at91_twi_probe()
232 dev->adapter.owner = THIS_MODULE; in at91_twi_probe()
233 dev->adapter.class = I2C_CLASS_DEPRECATED; in at91_twi_probe()
234 dev->adapter.dev.parent = dev->dev; in at91_twi_probe()
235 dev->adapter.nr = pdev->id; in at91_twi_probe()
236 dev->adapter.timeout = AT91_I2C_TIMEOUT; in at91_twi_probe()
237 dev->adapter.dev.of_node = pdev->dev.of_node; in at91_twi_probe()
239 dev->slave_detected = i2c_detect_slave_mode(&pdev->dev); in at91_twi_probe()
241 if (dev->slave_detected) in at91_twi_probe()
250 pm_runtime_set_autosuspend_delay(dev->dev, AUTOSUSPEND_TIMEOUT); in at91_twi_probe()
251 pm_runtime_use_autosuspend(dev->dev); in at91_twi_probe()
252 pm_runtime_set_active(dev->dev); in at91_twi_probe()
253 pm_runtime_enable(dev->dev); in at91_twi_probe()
255 rc = i2c_add_numbered_adapter(&dev->adapter); in at91_twi_probe()
257 clk_disable_unprepare(dev->clk); in at91_twi_probe()
259 pm_runtime_disable(dev->dev); in at91_twi_probe()
260 pm_runtime_set_suspended(dev->dev); in at91_twi_probe()
265 dev_info(dev->dev, "AT91 i2c bus driver (hw version: %#x).\n", in at91_twi_probe()
274 i2c_del_adapter(&dev->adapter); in at91_twi_remove()
275 clk_disable_unprepare(dev->clk); in at91_twi_remove()
277 pm_runtime_disable(dev->dev); in at91_twi_remove()
278 pm_runtime_set_suspended(dev->dev); in at91_twi_remove()
285 clk_disable_unprepare(twi_dev->clk); in at91_twi_runtime_suspend()
298 return clk_prepare_enable(twi_dev->clk); in at91_twi_runtime_resume()
360 MODULE_DESCRIPTION("I2C (TWI) driver for Atmel AT91");