Lines Matching refs:th

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