Lines Matching full:device
34 * host1x_subdev_add() - add a new subdevice with an associated device node
35 * @device: host1x device to add the subdevice to
37 * @np: device node
39 static int host1x_subdev_add(struct host1x_device *device, in host1x_subdev_add() argument
53 mutex_lock(&device->subdevs_lock); in host1x_subdev_add()
54 list_add_tail(&subdev->list, &device->subdevs); in host1x_subdev_add()
55 mutex_unlock(&device->subdevs_lock); in host1x_subdev_add()
61 err = host1x_subdev_add(device, driver, child); in host1x_subdev_add()
84 * host1x_device_parse_dt() - scan device tree and add matching subdevices
85 * @device: host1x logical device
88 static int host1x_device_parse_dt(struct host1x_device *device, in host1x_device_parse_dt() argument
93 for_each_child_of_node_scoped(device->dev.parent->of_node, np) { in host1x_device_parse_dt()
96 err = host1x_subdev_add(device, driver, np); in host1x_device_parse_dt()
105 static void host1x_subdev_register(struct host1x_device *device, in host1x_subdev_register() argument
114 * client with its parent device. in host1x_subdev_register()
116 mutex_lock(&device->subdevs_lock); in host1x_subdev_register()
117 mutex_lock(&device->clients_lock); in host1x_subdev_register()
118 list_move_tail(&client->list, &device->clients); in host1x_subdev_register()
119 list_move_tail(&subdev->list, &device->active); in host1x_subdev_register()
120 client->host = &device->dev; in host1x_subdev_register()
122 mutex_unlock(&device->clients_lock); in host1x_subdev_register()
123 mutex_unlock(&device->subdevs_lock); in host1x_subdev_register()
125 if (list_empty(&device->subdevs)) { in host1x_subdev_register()
126 err = device_add(&device->dev); in host1x_subdev_register()
128 dev_err(&device->dev, "failed to add: %d\n", err); in host1x_subdev_register()
130 device->registered = true; in host1x_subdev_register()
134 static void __host1x_subdev_unregister(struct host1x_device *device, in __host1x_subdev_unregister() argument
143 if (list_empty(&device->subdevs)) { in __host1x_subdev_unregister()
144 if (device->registered) { in __host1x_subdev_unregister()
145 device->registered = false; in __host1x_subdev_unregister()
146 device_del(&device->dev); in __host1x_subdev_unregister()
154 mutex_lock(&device->clients_lock); in __host1x_subdev_unregister()
157 list_move_tail(&subdev->list, &device->subdevs); in __host1x_subdev_unregister()
160 * when the device is about to be deleted. in __host1x_subdev_unregister()
164 * also when the composite device is about to be removed. in __host1x_subdev_unregister()
167 mutex_unlock(&device->clients_lock); in __host1x_subdev_unregister()
170 static void host1x_subdev_unregister(struct host1x_device *device, in host1x_subdev_unregister() argument
173 mutex_lock(&device->subdevs_lock); in host1x_subdev_unregister()
174 __host1x_subdev_unregister(device, subdev); in host1x_subdev_unregister()
175 mutex_unlock(&device->subdevs_lock); in host1x_subdev_unregister()
179 * host1x_device_init() - initialize a host1x logical device
180 * @device: host1x logical device
182 * The driver for the host1x logical device can call this during execution of
188 int host1x_device_init(struct host1x_device *device) in host1x_device_init() argument
193 mutex_lock(&device->clients_lock); in host1x_device_init()
195 list_for_each_entry(client, &device->clients, list) { in host1x_device_init()
199 dev_err(&device->dev, "failed to early initialize %s: %d\n", in host1x_device_init()
206 list_for_each_entry(client, &device->clients, list) { in host1x_device_init()
210 dev_err(&device->dev, in host1x_device_init()
218 mutex_unlock(&device->clients_lock); in host1x_device_init()
223 list_for_each_entry_continue_reverse(client, &device->clients, list) in host1x_device_init()
228 client = list_entry(&device->clients, struct host1x_client, list); in host1x_device_init()
231 list_for_each_entry_continue_reverse(client, &device->clients, list) in host1x_device_init()
235 mutex_unlock(&device->clients_lock); in host1x_device_init()
241 * host1x_device_exit() - uninitialize host1x logical device
242 * @device: host1x logical device
244 * When the driver for a host1x logical device is unloaded, it can call this
249 int host1x_device_exit(struct host1x_device *device) in host1x_device_exit() argument
254 mutex_lock(&device->clients_lock); in host1x_device_exit()
256 list_for_each_entry_reverse(client, &device->clients, list) { in host1x_device_exit()
260 dev_err(&device->dev, in host1x_device_exit()
263 mutex_unlock(&device->clients_lock); in host1x_device_exit()
269 list_for_each_entry_reverse(client, &device->clients, list) { in host1x_device_exit()
273 dev_err(&device->dev, "failed to late cleanup %s: %d\n", in host1x_device_exit()
275 mutex_unlock(&device->clients_lock); in host1x_device_exit()
281 mutex_unlock(&device->clients_lock); in host1x_device_exit()
290 struct host1x_device *device; in host1x_add_client() local
295 list_for_each_entry(device, &host1x->devices, list) { in host1x_add_client()
296 list_for_each_entry(subdev, &device->subdevs, list) { in host1x_add_client()
298 host1x_subdev_register(device, subdev, client); in host1x_add_client()
312 struct host1x_device *device, *dt; in host1x_del_client() local
317 list_for_each_entry_safe(device, dt, &host1x->devices, list) { in host1x_del_client()
318 list_for_each_entry(subdev, &device->active, list) { in host1x_del_client()
320 host1x_subdev_unregister(device, subdev); in host1x_del_client()
331 static int host1x_device_match(struct device *dev, const struct device_driver *drv) in host1x_device_match()
341 static int host1x_device_uevent(const struct device *dev, in host1x_device_uevent()
349 static int host1x_device_probe(struct device *dev) in host1x_device_probe()
352 struct host1x_device *device = to_host1x_device(dev); in host1x_device_probe() local
355 return driver->probe(device); in host1x_device_probe()
360 static void host1x_device_remove(struct device *dev) in host1x_device_remove()
363 struct host1x_device *device = to_host1x_device(dev); in host1x_device_remove() local
366 driver->remove(device); in host1x_device_remove()
369 static void host1x_device_shutdown(struct device *dev) in host1x_device_shutdown()
372 struct host1x_device *device = to_host1x_device(dev); in host1x_device_shutdown() local
375 driver->shutdown(device); in host1x_device_shutdown()
398 static void __host1x_device_del(struct host1x_device *device) in __host1x_device_del() argument
403 mutex_lock(&device->subdevs_lock); in __host1x_device_del()
406 list_for_each_entry_safe(subdev, sd, &device->active, list) { in __host1x_device_del()
418 __host1x_subdev_unregister(device, subdev); in __host1x_device_del()
427 list_for_each_entry_safe(subdev, sd, &device->subdevs, list) in __host1x_device_del()
430 mutex_unlock(&device->subdevs_lock); in __host1x_device_del()
434 mutex_lock(&device->clients_lock); in __host1x_device_del()
436 list_for_each_entry_safe(client, cl, &device->clients, list) in __host1x_device_del()
439 mutex_unlock(&device->clients_lock); in __host1x_device_del()
442 /* finally remove the device */ in __host1x_device_del()
443 list_del_init(&device->list); in __host1x_device_del()
446 static void host1x_device_release(struct device *dev) in host1x_device_release()
448 struct host1x_device *device = to_host1x_device(dev); in host1x_device_release() local
450 __host1x_device_del(device); in host1x_device_release()
451 kfree(device); in host1x_device_release()
459 struct host1x_device *device; in host1x_device_add() local
462 device = kzalloc_obj(*device); in host1x_device_add()
463 if (!device) in host1x_device_add()
466 device_initialize(&device->dev); in host1x_device_add()
468 mutex_init(&device->subdevs_lock); in host1x_device_add()
469 INIT_LIST_HEAD(&device->subdevs); in host1x_device_add()
470 INIT_LIST_HEAD(&device->active); in host1x_device_add()
471 mutex_init(&device->clients_lock); in host1x_device_add()
472 INIT_LIST_HEAD(&device->clients); in host1x_device_add()
473 INIT_LIST_HEAD(&device->list); in host1x_device_add()
474 device->driver = driver; in host1x_device_add()
476 device->dev.coherent_dma_mask = host1x->dev->coherent_dma_mask; in host1x_device_add()
477 device->dev.dma_mask = &device->dev.coherent_dma_mask; in host1x_device_add()
478 dev_set_name(&device->dev, "%s", driver->driver.name); in host1x_device_add()
479 device->dev.release = host1x_device_release; in host1x_device_add()
480 device->dev.bus = &host1x_bus_type; in host1x_device_add()
481 device->dev.parent = host1x->dev; in host1x_device_add()
483 device->dev.dma_parms = &device->dma_parms; in host1x_device_add()
484 dma_set_max_seg_size(&device->dev, UINT_MAX); in host1x_device_add()
486 err = host1x_device_parse_dt(device, driver); in host1x_device_add()
488 kfree(device); in host1x_device_add()
492 list_add_tail(&device->list, &host1x->devices); in host1x_device_add()
497 list_for_each_entry(subdev, &device->subdevs, list) { in host1x_device_add()
499 host1x_subdev_register(device, subdev, client); in host1x_device_add()
508 * Add device even if there are no subdevs to ensure syncpoint functionality in host1x_device_add()
511 if (list_empty(&device->subdevs)) { in host1x_device_add()
512 err = device_add(&device->dev); in host1x_device_add()
514 dev_err(&device->dev, "failed to add device: %d\n", err); in host1x_device_add()
516 device->registered = true; in host1x_device_add()
523 * Removes a device by first unregistering any subdevices and then removing
529 struct host1x_device *device) in host1x_device_del() argument
531 if (device->registered) { in host1x_device_del()
532 device->registered = false; in host1x_device_del()
533 device_del(&device->dev); in host1x_device_del()
536 put_device(&device->dev); in host1x_device_del()
542 struct host1x_device *device; in host1x_attach_driver() local
547 list_for_each_entry(device, &host1x->devices, list) { in host1x_attach_driver()
548 if (device->driver == driver) { in host1x_attach_driver()
556 dev_err(host1x->dev, "failed to allocate device: %d\n", err); in host1x_attach_driver()
564 struct host1x_device *device, *tmp; in host1x_detach_driver() local
568 list_for_each_entry_safe(device, tmp, &host1x->devices, list) in host1x_detach_driver()
569 if (device->driver == driver) in host1x_detach_driver()
570 host1x_device_del(host1x, device); in host1x_detach_driver()
578 struct host1x_device *device; in host1x_devices_show() local
582 list_for_each_entry(device, &host1x->devices, list) { in host1x_devices_show()
585 seq_printf(s, "%s\n", dev_name(&device->dev)); in host1x_devices_show()
587 mutex_lock(&device->subdevs_lock); in host1x_devices_show()
589 list_for_each_entry(subdev, &device->active, list) in host1x_devices_show()
593 list_for_each_entry(subdev, &device->subdevs, list) in host1x_devices_show()
596 mutex_unlock(&device->subdevs_lock); in host1x_devices_show()
666 * registration of the driver actually triggers tho logical device creation.
667 * A logical device will be created for each host1x instance.
752 * device and call host1x_device_init(), which will in turn call each client's
785 * device has already been initialized, it will be torn down.
890 struct host1x_bo_mapping *host1x_bo_pin(struct device *dev, struct host1x_bo *bo, in host1x_bo_pin()