Lines Matching refs:th
106 struct intel_th *th = to_intel_th(hub); in intel_th_remove() local
119 for (i = 0, lowest = -1; i < th->num_thdevs; i++) { 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()
143 th->num_thdevs = lowest; in intel_th_remove()
192 struct intel_th *th = to_intel_th(thdev); in intel_th_output_devnode() local
196 node = kasprintf(GFP_KERNEL, "intel_th%d/%s%d", th->id, in intel_th_output_devnode()
199 node = kasprintf(GFP_KERNEL, "intel_th%d/%s", th->id, in intel_th_output_devnode()
222 struct intel_th *th = to_intel_th(thdev); in intel_th_output_activate() local
233 if (th->activate) in intel_th_output_activate()
234 ret = th->activate(th); in intel_th_output_activate()
249 if (th->deactivate) in intel_th_output_activate()
250 th->deactivate(th); in intel_th_output_activate()
263 struct intel_th *th = to_intel_th(thdev); in intel_th_output_deactivate() local
273 if (th->deactivate) in intel_th_output_deactivate()
274 th->deactivate(th); in intel_th_output_deactivate()
355 intel_th_device_alloc(struct intel_th *th, unsigned int type, const char *name, in intel_th_device_alloc() argument
362 parent = &th->hub->dev; in intel_th_device_alloc()
364 parent = th->dev; 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()
569 struct intel_th *th = container_of(work, struct intel_th, in __intel_th_request_hub_module() local
572 request_module("intel_th_%s", th->hub->name); in __intel_th_request_hub_module()
575 static int intel_th_request_hub_module(struct intel_th *th) in intel_th_request_hub_module() argument
577 INIT_WORK(&th->request_module_work, __intel_th_request_hub_module); in intel_th_request_hub_module()
578 schedule_work(&th->request_module_work); in intel_th_request_hub_module()
583 static void intel_th_request_hub_module_flush(struct intel_th *th) in intel_th_request_hub_module_flush() argument
585 flush_work(&th->request_module_work); in intel_th_request_hub_module_flush()
588 static inline int intel_th_request_hub_module(struct intel_th *th) in intel_th_request_hub_module() argument
593 static inline void intel_th_request_hub_module_flush(struct intel_th *th) in intel_th_request_hub_module_flush() argument
599 intel_th_subdevice_alloc(struct intel_th *th, in intel_th_subdevice_alloc() argument
607 thdev = intel_th_device_alloc(th, subdev->type, subdev->name, in intel_th_subdevice_alloc()
612 thdev->drvdata = th->drvdata; in intel_th_subdevice_alloc()
618 struct resource *devres = th->resource; in intel_th_subdevice_alloc()
629 if (bar >= th->num_resources) in intel_th_subdevice_alloc()
639 dev_dbg(th->dev, "%s:%d @ %pR\n", in intel_th_subdevice_alloc()
646 if (INTEL_TH_CAP(th, has_mintctl) && th->irq != -1) in intel_th_subdevice_alloc()
647 res[r].start = th->irq; in intel_th_subdevice_alloc()
657 thdev->dev.devt = MKDEV(th->major, th->num_thdevs); in intel_th_subdevice_alloc()
663 INTEL_TH_CAP(th, host_mode_only) ? true : host_mode; in intel_th_subdevice_alloc()
664 th->hub = thdev; in intel_th_subdevice_alloc()
673 err = intel_th_request_hub_module(th); in intel_th_subdevice_alloc()
698 int intel_th_output_enable(struct intel_th *th, unsigned int otype) in intel_th_output_enable() argument
703 for (src = 0, dst = 0; dst <= th->num_thdevs; src++, dst++) { in intel_th_output_enable()
718 for (; dst < th->num_thdevs; dst++) { in intel_th_output_enable()
719 if (th->thdev[dst]->type != INTEL_TH_OUTPUT) in intel_th_output_enable()
722 if (th->thdev[dst]->output.type != otype) in intel_th_output_enable()
732 if (dst == th->num_thdevs) in intel_th_output_enable()
739 thdev = intel_th_subdevice_alloc(th, &intel_th_subdevices[src]); in intel_th_output_enable()
743 th->thdev[th->num_thdevs++] = thdev; in intel_th_output_enable()
749 static int intel_th_populate(struct intel_th *th) in intel_th_populate() argument
760 if ((INTEL_TH_CAP(th, host_mode_only) || host_mode) && in intel_th_populate()
772 thdev = intel_th_subdevice_alloc(th, subdev); in intel_th_populate()
782 th->thdev[th->num_thdevs++] = thdev; in intel_th_populate()
823 struct intel_th *th = data; in intel_th_irq() local
828 for (i = 0; i < th->num_thdevs; i++) { in intel_th_irq()
829 if (th->thdev[i]->type != INTEL_TH_OUTPUT) in intel_th_irq()
832 d = to_intel_th_driver(th->thdev[i]->dev.driver); in intel_th_irq()
834 ret |= d->irq(th->thdev[i]); in intel_th_irq()
851 struct intel_th *th; in intel_th_alloc() local
853 th = kzalloc(sizeof(*th), GFP_KERNEL); in intel_th_alloc()
854 if (!th) in intel_th_alloc()
857 th->id = ida_simple_get(&intel_th_ida, 0, 0, GFP_KERNEL); in intel_th_alloc()
858 if (th->id < 0) { in intel_th_alloc()
859 err = th->id; in intel_th_alloc()
863 th->major = __register_chrdev(0, 0, TH_POSSIBLE_OUTPUTS, in intel_th_alloc()
865 if (th->major < 0) { in intel_th_alloc()
866 err = th->major; in intel_th_alloc()
869 th->irq = -1; in intel_th_alloc()
870 th->dev = dev; in intel_th_alloc()
871 th->drvdata = drvdata; in intel_th_alloc()
876 th->resource[nr_mmios++] = devres[r]; in intel_th_alloc()
881 dev_name(dev), th); in intel_th_alloc()
885 if (th->irq == -1) in intel_th_alloc()
886 th->irq = devres[r].start; in intel_th_alloc()
887 th->num_irqs++; in intel_th_alloc()
895 th->num_resources = nr_mmios; in intel_th_alloc()
897 dev_set_drvdata(dev, th); in intel_th_alloc()
903 err = intel_th_populate(th); in intel_th_alloc()
906 intel_th_free(th); in intel_th_alloc()
910 return th; in intel_th_alloc()
913 __unregister_chrdev(th->major, 0, TH_POSSIBLE_OUTPUTS, in intel_th_alloc()
917 ida_simple_remove(&intel_th_ida, th->id); in intel_th_alloc()
920 kfree(th); in intel_th_alloc()
926 void intel_th_free(struct intel_th *th) in intel_th_free() argument
930 intel_th_request_hub_module_flush(th); in intel_th_free()
932 intel_th_device_remove(th->hub); in intel_th_free()
933 for (i = 0; i < th->num_thdevs; i++) { in intel_th_free()
934 if (th->thdev[i] != th->hub) in intel_th_free()
935 intel_th_device_remove(th->thdev[i]); in intel_th_free()
936 th->thdev[i] = NULL; in intel_th_free()
939 th->num_thdevs = 0; in intel_th_free()
941 for (i = 0; i < th->num_irqs; i++) in intel_th_free()
942 devm_free_irq(th->dev, th->irq + i, th); in intel_th_free()
944 pm_runtime_get_sync(th->dev); in intel_th_free()
945 pm_runtime_forbid(th->dev); in intel_th_free()
947 __unregister_chrdev(th->major, 0, TH_POSSIBLE_OUTPUTS, in intel_th_free()
950 ida_simple_remove(&intel_th_ida, th->id); in intel_th_free()
952 kfree(th); in intel_th_free()