Lines Matching refs:thdev
32 struct intel_th_device *thdev = to_intel_th_device(dev); in intel_th_match() local
34 if (thdev->type == INTEL_TH_SWITCH && in intel_th_match()
38 return !strcmp(thdev->name, driver->name); in intel_th_match()
51 struct intel_th_device *thdev = to_intel_th_device(dev); in intel_th_probe() local
56 if (thdev->type == INTEL_TH_SWITCH) in intel_th_probe()
57 hub = thdev; in intel_th_probe()
75 ret = sysfs_create_group(&thdev->dev.kobj, thdrv->attr_group); in intel_th_probe()
80 if (thdev->type == INTEL_TH_OUTPUT && in intel_th_probe()
81 !intel_th_output_assigned(thdev)) in intel_th_probe()
83 ret = hubdrv->assign(hub, thdev); in intel_th_probe()
87 thdrv->remove(thdev); in intel_th_probe()
96 static void intel_th_device_remove(struct intel_th_device *thdev);
101 struct intel_th_device *thdev = to_intel_th_device(dev); in intel_th_remove() local
102 struct intel_th_device *hub = to_intel_th_hub(thdev); in intel_th_remove()
105 if (thdev->type == INTEL_TH_SWITCH) { in intel_th_remove()
110 err = device_for_each_child(dev, thdev, intel_th_child_remove); in intel_th_remove()
125 if (th->thdev[i]->type != INTEL_TH_OUTPUT) { in intel_th_remove()
127 th->thdev[lowest] = th->thdev[i]; in intel_th_remove()
128 th->thdev[i] = NULL; in intel_th_remove()
138 intel_th_device_remove(th->thdev[i]); in intel_th_remove()
139 th->thdev[i] = NULL; in intel_th_remove()
147 sysfs_remove_group(&thdev->dev.kobj, thdrv->attr_group); in intel_th_remove()
151 thdrv->remove(thdev); in intel_th_remove()
153 if (intel_th_output_assigned(thdev)) { in intel_th_remove()
159 hubdrv->unassign(hub, thdev); in intel_th_remove()
176 static void intel_th_device_free(struct intel_th_device *thdev);
191 struct intel_th_device *thdev = to_intel_th_device(dev); in intel_th_output_devnode() local
192 struct intel_th *th = to_intel_th(thdev); in intel_th_output_devnode()
195 if (thdev->id >= 0) in intel_th_output_devnode()
197 thdev->name, thdev->id); in intel_th_output_devnode()
200 thdev->name); in intel_th_output_devnode()
208 struct intel_th_device *thdev = to_intel_th_device(dev); in port_show() local
210 if (thdev->output.port >= 0) in port_show()
211 return scnprintf(buf, PAGE_SIZE, "%u\n", thdev->output.port); in port_show()
218 static int intel_th_output_activate(struct intel_th_device *thdev) in intel_th_output_activate() argument
221 to_intel_th_driver_or_null(thdev->dev.driver); in intel_th_output_activate()
222 struct intel_th *th = to_intel_th(thdev); in intel_th_output_activate()
231 pm_runtime_get_sync(&thdev->dev); in intel_th_output_activate()
239 ret = thdrv->activate(thdev); in intel_th_output_activate()
241 intel_th_trace_enable(thdev); in intel_th_output_activate()
253 pm_runtime_put(&thdev->dev); in intel_th_output_activate()
259 static void intel_th_output_deactivate(struct intel_th_device *thdev) in intel_th_output_deactivate() argument
262 to_intel_th_driver_or_null(thdev->dev.driver); in intel_th_output_deactivate()
263 struct intel_th *th = to_intel_th(thdev); in intel_th_output_deactivate()
269 thdrv->deactivate(thdev); in intel_th_output_deactivate()
271 intel_th_trace_disable(thdev); in intel_th_output_deactivate()
276 pm_runtime_put(&thdev->dev); in intel_th_output_deactivate()
283 struct intel_th_device *thdev = to_intel_th_device(dev); in active_show() local
285 return scnprintf(buf, PAGE_SIZE, "%d\n", thdev->output.active); in active_show()
291 struct intel_th_device *thdev = to_intel_th_device(dev); in active_store() local
299 if (!!val != thdev->output.active) { in active_store()
301 ret = intel_th_output_activate(thdev); in active_store()
303 intel_th_output_deactivate(thdev); in active_store()
359 struct intel_th_device *thdev; in intel_th_device_alloc() local
366 thdev = kzalloc(sizeof(*thdev) + strlen(name) + 1, GFP_KERNEL); in intel_th_device_alloc()
367 if (!thdev) in intel_th_device_alloc()
370 thdev->id = id; in intel_th_device_alloc()
371 thdev->type = type; in intel_th_device_alloc()
373 strcpy(thdev->name, name); in intel_th_device_alloc()
374 device_initialize(&thdev->dev); in intel_th_device_alloc()
375 thdev->dev.bus = &intel_th_bus; in intel_th_device_alloc()
376 thdev->dev.type = intel_th_device_type[type]; in intel_th_device_alloc()
377 thdev->dev.parent = parent; in intel_th_device_alloc()
378 thdev->dev.dma_mask = parent->dma_mask; in intel_th_device_alloc()
379 thdev->dev.dma_parms = parent->dma_parms; in intel_th_device_alloc()
380 dma_set_coherent_mask(&thdev->dev, parent->coherent_dma_mask); in intel_th_device_alloc()
382 dev_set_name(&thdev->dev, "%d-%s%d", th->id, name, id); in intel_th_device_alloc()
384 dev_set_name(&thdev->dev, "%d-%s", th->id, name); in intel_th_device_alloc()
386 return thdev; in intel_th_device_alloc()
389 static int intel_th_device_add_resources(struct intel_th_device *thdev, in intel_th_device_add_resources() argument
398 thdev->resource = r; in intel_th_device_add_resources()
399 thdev->num_resources = nres; in intel_th_device_add_resources()
404 static void intel_th_device_remove(struct intel_th_device *thdev) in intel_th_device_remove() argument
406 device_del(&thdev->dev); in intel_th_device_remove()
407 put_device(&thdev->dev); in intel_th_device_remove()
410 static void intel_th_device_free(struct intel_th_device *thdev) in intel_th_device_free() argument
412 kfree(thdev->resource); in intel_th_device_free()
413 kfree(thdev); in intel_th_device_free()
602 struct intel_th_device *thdev; in intel_th_subdevice_alloc() local
607 thdev = intel_th_device_alloc(th, subdev->type, subdev->name, in intel_th_subdevice_alloc()
609 if (!thdev) in intel_th_subdevice_alloc()
612 thdev->drvdata = th->drvdata; in intel_th_subdevice_alloc()
651 err = intel_th_device_add_resources(thdev, res, subdev->nres); in intel_th_subdevice_alloc()
653 put_device(&thdev->dev); in intel_th_subdevice_alloc()
659 thdev->dev.devt = MKDEV(th->major, th->num_thdevs); in intel_th_subdevice_alloc()
660 thdev->output.type = subdev->otype; in intel_th_subdevice_alloc()
661 thdev->output.port = -1; in intel_th_subdevice_alloc()
662 thdev->output.scratchpad = subdev->scrpd; in intel_th_subdevice_alloc()
664 thdev->host_mode = in intel_th_subdevice_alloc()
666 th->hub = thdev; in intel_th_subdevice_alloc()
669 err = device_add(&thdev->dev); in intel_th_subdevice_alloc()
671 put_device(&thdev->dev); in intel_th_subdevice_alloc()
682 return thdev; in intel_th_subdevice_alloc()
685 kfree(thdev->resource); in intel_th_subdevice_alloc()
688 put_device(&thdev->dev); in intel_th_subdevice_alloc()
704 struct intel_th_device *thdev; in intel_th_output_enable() local
723 if (th->thdev[dst]->type != INTEL_TH_OUTPUT) in intel_th_output_enable()
726 if (th->thdev[dst]->output.type != otype) in intel_th_output_enable()
743 thdev = intel_th_subdevice_alloc(th, &intel_th_subdevices[src]); in intel_th_output_enable()
744 if (IS_ERR(thdev)) in intel_th_output_enable()
745 return PTR_ERR(thdev); in intel_th_output_enable()
747 th->thdev[th->num_thdevs++] = thdev; in intel_th_output_enable()
761 struct intel_th_device *thdev; in intel_th_populate() local
776 thdev = intel_th_subdevice_alloc(th, subdev); in intel_th_populate()
778 if (IS_ERR(thdev)) { in intel_th_populate()
780 if (PTR_ERR(thdev) == -ENODEV) in intel_th_populate()
783 return PTR_ERR(thdev); in intel_th_populate()
786 th->thdev[th->num_thdevs++] = thdev; in intel_th_populate()
833 if (th->thdev[i]->type != INTEL_TH_OUTPUT) in intel_th_irq()
836 d = to_intel_th_driver(th->thdev[i]->dev.driver); in intel_th_irq()
838 ret |= d->irq(th->thdev[i]); in intel_th_irq()
940 if (th->thdev[i] != th->hub) in intel_th_free()
941 intel_th_device_remove(th->thdev[i]); in intel_th_free()
942 th->thdev[i] = NULL; in intel_th_free()
963 int intel_th_trace_enable(struct intel_th_device *thdev) in intel_th_trace_enable() argument
965 struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent); in intel_th_trace_enable()
971 if (WARN_ON_ONCE(thdev->type != INTEL_TH_OUTPUT)) in intel_th_trace_enable()
974 pm_runtime_get_sync(&thdev->dev); in intel_th_trace_enable()
975 hubdrv->enable(hub, &thdev->output); in intel_th_trace_enable()
985 int intel_th_trace_switch(struct intel_th_device *thdev) in intel_th_trace_switch() argument
987 struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent); in intel_th_trace_switch()
993 if (WARN_ON_ONCE(thdev->type != INTEL_TH_OUTPUT)) in intel_th_trace_switch()
996 hubdrv->trig_switch(hub, &thdev->output); in intel_th_trace_switch()
1006 int intel_th_trace_disable(struct intel_th_device *thdev) in intel_th_trace_disable() argument
1008 struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent); in intel_th_trace_disable()
1012 if (WARN_ON_ONCE(thdev->type != INTEL_TH_OUTPUT)) in intel_th_trace_disable()
1015 hubdrv->disable(hub, &thdev->output); in intel_th_trace_disable()
1016 pm_runtime_put(&thdev->dev); in intel_th_trace_disable()
1022 int intel_th_set_output(struct intel_th_device *thdev, in intel_th_set_output() argument
1025 struct intel_th_device *hub = to_intel_th_hub(thdev); in intel_th_set_output()