Lines Matching full:th
105 struct intel_th *th = to_intel_th(hub); in intel_th_remove() local
121 for (i = 0, lowest = -1; i < th->num_thdevs; i++) { in intel_th_remove()
124 * th->thdev[] array to lower positions to maintain 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()
145 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()
238 struct intel_th *th = to_intel_th(thdev); in intel_th_output_activate() local
249 if (th->activate) in intel_th_output_activate()
250 ret = th->activate(th); in intel_th_output_activate()
266 if (th->deactivate) in intel_th_output_activate()
267 th->deactivate(th); in intel_th_output_activate()
280 struct intel_th *th = to_intel_th(thdev); in intel_th_output_deactivate() local
290 if (th->deactivate) in intel_th_output_deactivate()
291 th->deactivate(th); in intel_th_output_deactivate()
372 intel_th_device_alloc(struct intel_th *th, unsigned int type, const char *name, in intel_th_device_alloc() argument
379 parent = &th->hub->dev; in intel_th_device_alloc()
381 parent = th->dev; 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()
586 struct intel_th *th = container_of(work, struct intel_th, in __intel_th_request_hub_module() local
589 request_module("intel_th_%s", th->hub->name); in __intel_th_request_hub_module()
592 static int intel_th_request_hub_module(struct intel_th *th) in intel_th_request_hub_module() argument
594 INIT_WORK(&th->request_module_work, __intel_th_request_hub_module); in intel_th_request_hub_module()
595 schedule_work(&th->request_module_work); in intel_th_request_hub_module()
600 static void intel_th_request_hub_module_flush(struct intel_th *th) in intel_th_request_hub_module_flush() argument
602 flush_work(&th->request_module_work); in intel_th_request_hub_module_flush()
605 static inline int intel_th_request_hub_module(struct intel_th *th) in intel_th_request_hub_module() argument
610 static inline void intel_th_request_hub_module_flush(struct intel_th *th) in intel_th_request_hub_module_flush() argument
616 intel_th_subdevice_alloc(struct intel_th *th, in intel_th_subdevice_alloc() argument
624 thdev = intel_th_device_alloc(th, subdev->type, subdev->name, in intel_th_subdevice_alloc()
629 thdev->drvdata = th->drvdata; in intel_th_subdevice_alloc()
635 struct resource *devres = th->resource; in intel_th_subdevice_alloc()
646 if (bar >= th->num_resources) in intel_th_subdevice_alloc()
656 dev_dbg(th->dev, "%s:%d @ %pR\n", in intel_th_subdevice_alloc()
663 if (INTEL_TH_CAP(th, has_mintctl) && th->irq != -1) in intel_th_subdevice_alloc()
664 res[r].start = th->irq; in intel_th_subdevice_alloc()
674 thdev->dev.devt = MKDEV(th->major, th->num_thdevs); in intel_th_subdevice_alloc()
680 INTEL_TH_CAP(th, host_mode_only) ? true : host_mode; in intel_th_subdevice_alloc()
681 th->hub = thdev; in intel_th_subdevice_alloc()
690 err = intel_th_request_hub_module(th); in intel_th_subdevice_alloc()
708 * @th: Intel TH instance
715 int intel_th_output_enable(struct intel_th *th, unsigned int otype) in intel_th_output_enable() argument
720 for (src = 0, dst = 0; dst <= th->num_thdevs; src++, dst++) { in intel_th_output_enable()
735 for (; dst < th->num_thdevs; dst++) { in intel_th_output_enable()
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()
747 * not matched in th::thdev[] in intel_th_output_enable()
749 if (dst == th->num_thdevs) in intel_th_output_enable()
756 thdev = intel_th_subdevice_alloc(th, &intel_th_subdevices[src]); in intel_th_output_enable()
760 th->thdev[th->num_thdevs++] = thdev; in intel_th_output_enable()
766 static int intel_th_populate(struct intel_th *th) in intel_th_populate() argument
777 if ((INTEL_TH_CAP(th, host_mode_only) || host_mode) && in intel_th_populate()
789 thdev = intel_th_subdevice_alloc(th, subdev); in intel_th_populate()
790 /* note: caller should free subdevices from th::thdev[] */ in intel_th_populate()
799 th->thdev[th->num_thdevs++] = thdev; in intel_th_populate()
840 struct intel_th *th = data; in intel_th_irq() local
845 for (i = 0; i < th->num_thdevs; i++) { in intel_th_irq()
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()
858 * intel_th_alloc() - allocate a new Intel TH device and its subdevices
868 struct intel_th *th; in intel_th_alloc() local
870 th = kzalloc(sizeof(*th), GFP_KERNEL); in intel_th_alloc()
871 if (!th) in intel_th_alloc()
874 th->id = ida_simple_get(&intel_th_ida, 0, 0, GFP_KERNEL); in intel_th_alloc()
875 if (th->id < 0) { in intel_th_alloc()
876 err = th->id; in intel_th_alloc()
880 th->major = __register_chrdev(0, 0, TH_POSSIBLE_OUTPUTS, in intel_th_alloc()
882 if (th->major < 0) { in intel_th_alloc()
883 err = th->major; in intel_th_alloc()
886 th->irq = -1; in intel_th_alloc()
887 th->dev = dev; in intel_th_alloc()
888 th->drvdata = drvdata; in intel_th_alloc()
893 th->resource[nr_mmios++] = devres[r]; in intel_th_alloc()
898 dev_name(dev), th); in intel_th_alloc()
902 if (th->irq == -1) in intel_th_alloc()
903 th->irq = devres[r].start; in intel_th_alloc()
904 th->num_irqs++; in intel_th_alloc()
912 th->num_resources = nr_mmios; in intel_th_alloc()
914 dev_set_drvdata(dev, th); in intel_th_alloc()
920 err = intel_th_populate(th); in intel_th_alloc()
923 intel_th_free(th); in intel_th_alloc()
927 return th; in intel_th_alloc()
930 __unregister_chrdev(th->major, 0, TH_POSSIBLE_OUTPUTS, in intel_th_alloc()
934 ida_simple_remove(&intel_th_ida, th->id); in intel_th_alloc()
937 kfree(th); in intel_th_alloc()
943 void intel_th_free(struct intel_th *th) in intel_th_free() argument
947 intel_th_request_hub_module_flush(th); in intel_th_free()
949 intel_th_device_remove(th->hub); in intel_th_free()
950 for (i = 0; i < th->num_thdevs; i++) { in intel_th_free()
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()
956 th->num_thdevs = 0; in intel_th_free()
958 for (i = 0; i < th->num_irqs; i++) in intel_th_free()
959 devm_free_irq(th->dev, th->irq + i, th); in intel_th_free()
961 pm_runtime_get_sync(th->dev); in intel_th_free()
962 pm_runtime_forbid(th->dev); in intel_th_free()
964 __unregister_chrdev(th->major, 0, TH_POSSIBLE_OUTPUTS, in intel_th_free()
967 ida_simple_remove(&intel_th_ida, th->id); in intel_th_free()
969 kfree(th); in intel_th_free()