Lines Matching full:i2c

3  * Intel Xe I2C attached Microcontroller Units (MCU)
12 #include <linux/i2c.h>
36 * DOC: Xe I2C devices
38 * Register a platform device for the I2C host controller (Synpsys DesignWare
39 * I2C) if the registers of that controller are mapped to the MMIO, and also the
40 * I2C client device for the Add-In Management Controller (the MCU) attached to
43 * See drivers/i2c/busses/i2c-designware-* for more information on the I2C host
50 PROPERTY_ENTRY_STRING("compatible", "intel,xe-i2c"),
65 struct xe_i2c *i2c = container_of(work, struct xe_i2c, work); in xe_i2c_client_work() local
69 .addr = i2c->ep.addr[1], in xe_i2c_client_work()
72 i2c->client[0] = i2c_new_client_device(i2c->adapter, &info); in xe_i2c_client_work()
77 struct xe_i2c *i2c = container_of(nb, struct xe_i2c, bus_notifier); in xe_i2c_notifier() local
82 adapter && dev->parent == &i2c->pdev->dev) { in xe_i2c_notifier()
83 i2c->adapter = adapter; in xe_i2c_notifier()
84 schedule_work(&i2c->work); in xe_i2c_notifier()
91 static int xe_i2c_register_adapter(struct xe_i2c *i2c) in xe_i2c_register_adapter() argument
93 struct pci_dev *pci = to_pci_dev(i2c->drm_dev); in xe_i2c_register_adapter()
114 if (i2c->adapter_irq) { in xe_i2c_register_adapter()
117 res = DEFINE_RES_IRQ_NAMED(i2c->adapter_irq, "xe_i2c"); in xe_i2c_register_adapter()
124 pdev->dev.parent = i2c->drm_dev; in xe_i2c_register_adapter()
126 i2c->adapter_node = fwnode; in xe_i2c_register_adapter()
127 i2c->pdev = pdev; in xe_i2c_register_adapter()
143 static void xe_i2c_unregister_adapter(struct xe_i2c *i2c) in xe_i2c_unregister_adapter() argument
145 platform_device_unregister(i2c->pdev); in xe_i2c_unregister_adapter()
146 fwnode_remove_software_node(i2c->adapter_node); in xe_i2c_unregister_adapter()
150 * xe_i2c_irq_handler: Handler for I2C interrupts
154 * Forward interrupts generated by the I2C host adapter to the I2C host adapter
159 if (!xe->i2c || !xe->i2c->adapter_irq) in xe_i2c_irq_handler()
163 generic_handle_irq_safe(xe->i2c->adapter_irq); in xe_i2c_irq_handler()
177 static int xe_i2c_create_irq(struct xe_i2c *i2c) in xe_i2c_create_irq() argument
181 if (!(i2c->ep.capabilities & XE_I2C_EP_CAP_IRQ)) in xe_i2c_create_irq()
184 domain = irq_domain_create_linear(dev_fwnode(i2c->drm_dev), 1, &xe_i2c_irq_ops, NULL); in xe_i2c_create_irq()
188 i2c->adapter_irq = irq_create_mapping(domain, 0); in xe_i2c_create_irq()
189 i2c->irqdomain = domain; in xe_i2c_create_irq()
194 static void xe_i2c_remove_irq(struct xe_i2c *i2c) in xe_i2c_remove_irq() argument
196 if (!i2c->irqdomain) in xe_i2c_remove_irq()
199 irq_dispose_mapping(i2c->adapter_irq); in xe_i2c_remove_irq()
200 irq_domain_remove(i2c->irqdomain); in xe_i2c_remove_irq()
205 struct xe_i2c *i2c = context; in xe_i2c_read() local
207 *val = xe_mmio_read32(i2c->mmio, XE_REG(reg + I2C_MEM_SPACE_OFFSET)); in xe_i2c_read()
214 struct xe_i2c *i2c = context; in xe_i2c_write() local
216 xe_mmio_write32(i2c->mmio, XE_REG(reg + I2C_MEM_SPACE_OFFSET), val); in xe_i2c_write()
233 if (!xe->i2c || xe->i2c->ep.cookie != XE_I2C_EP_COOKIE_DEVICE) in xe_i2c_pm_suspend()
244 if (!xe->i2c || xe->i2c->ep.cookie != XE_I2C_EP_COOKIE_DEVICE) in xe_i2c_pm_resume()
256 struct xe_i2c *i2c = data; in xe_i2c_remove() local
260 i2c_unregister_device(i2c->client[i]); in xe_i2c_remove()
262 bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier); in xe_i2c_remove()
263 xe_i2c_unregister_adapter(i2c); in xe_i2c_remove()
264 xe_i2c_remove_irq(i2c); in xe_i2c_remove()
268 * xe_i2c_probe: Probe the I2C host adapter and the I2C clients attached to it
271 * Register all the I2C devices described in the I2C Endpoint data structure.
280 struct xe_i2c *i2c; in xe_i2c_probe() local
293 i2c = devm_kzalloc(drm_dev, sizeof(*i2c), GFP_KERNEL); in xe_i2c_probe()
294 if (!i2c) in xe_i2c_probe()
297 INIT_WORK(&i2c->work, xe_i2c_client_work); in xe_i2c_probe()
298 i2c->mmio = xe_root_tile_mmio(xe); in xe_i2c_probe()
299 i2c->drm_dev = drm_dev; in xe_i2c_probe()
300 i2c->ep = ep; in xe_i2c_probe()
301 xe->i2c = i2c; in xe_i2c_probe()
306 regmap = devm_regmap_init(drm_dev, NULL, i2c, &i2c_regmap_config); in xe_i2c_probe()
310 i2c->bus_notifier.notifier_call = xe_i2c_notifier; in xe_i2c_probe()
311 ret = bus_register_notifier(&i2c_bus_type, &i2c->bus_notifier); in xe_i2c_probe()
315 ret = xe_i2c_create_irq(i2c); in xe_i2c_probe()
319 ret = xe_i2c_register_adapter(i2c); in xe_i2c_probe()
323 return devm_add_action_or_reset(drm_dev, xe_i2c_remove, i2c); in xe_i2c_probe()
326 xe_i2c_remove_irq(i2c); in xe_i2c_probe()
329 bus_unregister_notifier(&i2c_bus_type, &i2c->bus_notifier); in xe_i2c_probe()