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()
104 if (thdev->type == INTEL_TH_SWITCH) { in intel_th_remove()
114 device_for_each_child(dev, thdev, intel_th_child_remove); in intel_th_remove()
127 if (th->thdev[i]->type != INTEL_TH_OUTPUT) { in intel_th_remove()
129 th->thdev[lowest] = th->thdev[i]; in intel_th_remove()
130 th->thdev[i] = NULL; in intel_th_remove()
140 intel_th_device_remove(th->thdev[i]); in intel_th_remove()
141 th->thdev[i] = NULL; in intel_th_remove()
149 sysfs_remove_group(&thdev->dev.kobj, thdrv->attr_group); in intel_th_remove()
153 thdrv->remove(thdev); in intel_th_remove()
155 if (intel_th_output_assigned(thdev)) { in intel_th_remove()
161 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 void intel_th_trace_prepare(struct intel_th_device *thdev) in intel_th_trace_prepare() argument
220 struct intel_th_device *hub = to_intel_th_hub(thdev); in intel_th_trace_prepare()
226 if (thdev->type != INTEL_TH_OUTPUT) in intel_th_trace_prepare()
229 pm_runtime_get_sync(&thdev->dev); in intel_th_trace_prepare()
230 hubdrv->prepare(hub, &thdev->output); in intel_th_trace_prepare()
231 pm_runtime_put(&thdev->dev); in intel_th_trace_prepare()
234 static int intel_th_output_activate(struct intel_th_device *thdev) in intel_th_output_activate() argument
237 to_intel_th_driver_or_null(thdev->dev.driver); in intel_th_output_activate()
238 struct intel_th *th = to_intel_th(thdev); in intel_th_output_activate()
247 pm_runtime_get_sync(&thdev->dev); in intel_th_output_activate()
254 intel_th_trace_prepare(thdev); in intel_th_output_activate()
256 ret = thdrv->activate(thdev); in intel_th_output_activate()
258 intel_th_trace_enable(thdev); in intel_th_output_activate()
270 pm_runtime_put(&thdev->dev); in intel_th_output_activate()
276 static void intel_th_output_deactivate(struct intel_th_device *thdev) in intel_th_output_deactivate() argument
279 to_intel_th_driver_or_null(thdev->dev.driver); in intel_th_output_deactivate()
280 struct intel_th *th = to_intel_th(thdev); in intel_th_output_deactivate()
286 thdrv->deactivate(thdev); in intel_th_output_deactivate()
288 intel_th_trace_disable(thdev); in intel_th_output_deactivate()
293 pm_runtime_put(&thdev->dev); in intel_th_output_deactivate()
300 struct intel_th_device *thdev = to_intel_th_device(dev); in active_show() local
302 return scnprintf(buf, PAGE_SIZE, "%d\n", thdev->output.active); in active_show()
308 struct intel_th_device *thdev = to_intel_th_device(dev); in active_store() local
316 if (!!val != thdev->output.active) { in active_store()
318 ret = intel_th_output_activate(thdev); in active_store()
320 intel_th_output_deactivate(thdev); in active_store()
376 struct intel_th_device *thdev; in intel_th_device_alloc() local
383 thdev = kzalloc(sizeof(*thdev) + strlen(name) + 1, GFP_KERNEL); in intel_th_device_alloc()
384 if (!thdev) in intel_th_device_alloc()
387 thdev->id = id; in intel_th_device_alloc()
388 thdev->type = type; in intel_th_device_alloc()
390 strcpy(thdev->name, name); in intel_th_device_alloc()
391 device_initialize(&thdev->dev); in intel_th_device_alloc()
392 thdev->dev.bus = &intel_th_bus; in intel_th_device_alloc()
393 thdev->dev.type = intel_th_device_type[type]; in intel_th_device_alloc()
394 thdev->dev.parent = parent; in intel_th_device_alloc()
395 thdev->dev.dma_mask = parent->dma_mask; in intel_th_device_alloc()
396 thdev->dev.dma_parms = parent->dma_parms; in intel_th_device_alloc()
397 dma_set_coherent_mask(&thdev->dev, parent->coherent_dma_mask); in intel_th_device_alloc()
399 dev_set_name(&thdev->dev, "%d-%s%d", th->id, name, id); in intel_th_device_alloc()
401 dev_set_name(&thdev->dev, "%d-%s", th->id, name); in intel_th_device_alloc()
403 return thdev; in intel_th_device_alloc()
406 static int intel_th_device_add_resources(struct intel_th_device *thdev, in intel_th_device_add_resources() argument
415 thdev->resource = r; in intel_th_device_add_resources()
416 thdev->num_resources = nres; in intel_th_device_add_resources()
421 static void intel_th_device_remove(struct intel_th_device *thdev) in intel_th_device_remove() argument
423 device_del(&thdev->dev); in intel_th_device_remove()
424 put_device(&thdev->dev); in intel_th_device_remove()
427 static void intel_th_device_free(struct intel_th_device *thdev) in intel_th_device_free() argument
429 kfree(thdev->resource); in intel_th_device_free()
430 kfree(thdev); in intel_th_device_free()
619 struct intel_th_device *thdev; in intel_th_subdevice_alloc() local
624 thdev = intel_th_device_alloc(th, subdev->type, subdev->name, in intel_th_subdevice_alloc()
626 if (!thdev) in intel_th_subdevice_alloc()
629 thdev->drvdata = th->drvdata; in intel_th_subdevice_alloc()
668 err = intel_th_device_add_resources(thdev, res, subdev->nres); in intel_th_subdevice_alloc()
674 thdev->dev.devt = MKDEV(th->major, th->num_thdevs); in intel_th_subdevice_alloc()
675 thdev->output.type = subdev->otype; in intel_th_subdevice_alloc()
676 thdev->output.port = -1; in intel_th_subdevice_alloc()
677 thdev->output.scratchpad = subdev->scrpd; in intel_th_subdevice_alloc()
679 thdev->host_mode = in intel_th_subdevice_alloc()
681 th->hub = thdev; in intel_th_subdevice_alloc()
684 err = device_add(&thdev->dev); in intel_th_subdevice_alloc()
695 return thdev; in intel_th_subdevice_alloc()
698 kfree(thdev->resource); in intel_th_subdevice_alloc()
701 put_device(&thdev->dev); in intel_th_subdevice_alloc()
717 struct intel_th_device *thdev; in intel_th_output_enable() local
736 if (th->thdev[dst]->type != INTEL_TH_OUTPUT) in intel_th_output_enable()
739 if (th->thdev[dst]->output.type != otype) in intel_th_output_enable()
756 thdev = intel_th_subdevice_alloc(th, &intel_th_subdevices[src]); in intel_th_output_enable()
757 if (IS_ERR(thdev)) in intel_th_output_enable()
758 return PTR_ERR(thdev); in intel_th_output_enable()
760 th->thdev[th->num_thdevs++] = thdev; in intel_th_output_enable()
774 struct intel_th_device *thdev; in intel_th_populate() local
789 thdev = intel_th_subdevice_alloc(th, subdev); in intel_th_populate()
791 if (IS_ERR(thdev)) { in intel_th_populate()
793 if (PTR_ERR(thdev) == -ENODEV) in intel_th_populate()
796 return PTR_ERR(thdev); in intel_th_populate()
799 th->thdev[th->num_thdevs++] = thdev; in intel_th_populate()
846 if (th->thdev[i]->type != INTEL_TH_OUTPUT) in intel_th_irq()
849 d = to_intel_th_driver(th->thdev[i]->dev.driver); in intel_th_irq()
851 ret |= d->irq(th->thdev[i]); in intel_th_irq()
951 if (th->thdev[i] != th->hub) in intel_th_free()
952 intel_th_device_remove(th->thdev[i]); in intel_th_free()
953 th->thdev[i] = NULL; in intel_th_free()
977 int intel_th_trace_enable(struct intel_th_device *thdev) in intel_th_trace_enable() argument
979 struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent); in intel_th_trace_enable()
985 if (WARN_ON_ONCE(thdev->type != INTEL_TH_OUTPUT)) in intel_th_trace_enable()
988 pm_runtime_get_sync(&thdev->dev); in intel_th_trace_enable()
989 hubdrv->enable(hub, &thdev->output); in intel_th_trace_enable()
999 int intel_th_trace_switch(struct intel_th_device *thdev) in intel_th_trace_switch() argument
1001 struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent); in intel_th_trace_switch()
1007 if (WARN_ON_ONCE(thdev->type != INTEL_TH_OUTPUT)) in intel_th_trace_switch()
1010 hubdrv->trig_switch(hub, &thdev->output); in intel_th_trace_switch()
1020 int intel_th_trace_disable(struct intel_th_device *thdev) in intel_th_trace_disable() argument
1022 struct intel_th_device *hub = to_intel_th_device(thdev->dev.parent); in intel_th_trace_disable()
1026 if (WARN_ON_ONCE(thdev->type != INTEL_TH_OUTPUT)) in intel_th_trace_disable()
1029 hubdrv->disable(hub, &thdev->output); in intel_th_trace_disable()
1030 pm_runtime_put(&thdev->dev); in intel_th_trace_disable()
1036 int intel_th_set_output(struct intel_th_device *thdev, in intel_th_set_output() argument
1039 struct intel_th_device *hub = to_intel_th_hub(thdev); in intel_th_set_output()