Lines Matching refs:csdev
31 struct coresight_device *csdev; member
59 struct coresight_device *csdev, *i_csdev; in coresight_id_match() local
61 csdev = data; in coresight_id_match()
68 if (i_csdev == csdev || !i_csdev->enable || in coresight_id_match()
73 trace_id = source_ops(csdev)->trace_id(csdev); in coresight_id_match()
83 static int coresight_source_is_unique(struct coresight_device *csdev) in coresight_source_is_unique() argument
85 int trace_id = source_ops(csdev)->trace_id(csdev); in coresight_source_is_unique()
92 csdev, coresight_id_match); in coresight_source_is_unique()
95 static int coresight_find_link_inport(struct coresight_device *csdev, in coresight_find_link_inport() argument
103 if (conn->child_dev == csdev) in coresight_find_link_inport()
107 dev_err(&csdev->dev, "couldn't find inport, parent: %s, child: %s\n", in coresight_find_link_inport()
108 dev_name(&parent->dev), dev_name(&csdev->dev)); in coresight_find_link_inport()
113 static int coresight_find_link_outport(struct coresight_device *csdev, in coresight_find_link_outport() argument
119 for (i = 0; i < csdev->nr_outport; i++) { in coresight_find_link_outport()
120 conn = &csdev->conns[i]; in coresight_find_link_outport()
125 dev_err(&csdev->dev, "couldn't find outport, parent: %s, child: %s\n", in coresight_find_link_outport()
126 dev_name(&csdev->dev), dev_name(&child->dev)); in coresight_find_link_outport()
131 static int coresight_enable_sink(struct coresight_device *csdev, u32 mode) in coresight_enable_sink() argument
135 if (!csdev->enable) { in coresight_enable_sink()
136 if (sink_ops(csdev)->enable) { in coresight_enable_sink()
137 ret = sink_ops(csdev)->enable(csdev, mode); in coresight_enable_sink()
141 csdev->enable = true; in coresight_enable_sink()
144 atomic_inc(csdev->refcnt); in coresight_enable_sink()
149 static void coresight_disable_sink(struct coresight_device *csdev) in coresight_disable_sink() argument
151 if (atomic_dec_return(csdev->refcnt) == 0) { in coresight_disable_sink()
152 if (sink_ops(csdev)->disable) { in coresight_disable_sink()
153 sink_ops(csdev)->disable(csdev); in coresight_disable_sink()
154 csdev->enable = false; in coresight_disable_sink()
159 static int coresight_enable_link(struct coresight_device *csdev, in coresight_enable_link() argument
170 inport = coresight_find_link_inport(csdev, parent); in coresight_enable_link()
171 outport = coresight_find_link_outport(csdev, child); in coresight_enable_link()
172 link_subtype = csdev->subtype.link_subtype; in coresight_enable_link()
184 if (atomic_inc_return(&csdev->refcnt[refport]) == 1) { in coresight_enable_link()
185 if (link_ops(csdev)->enable) { in coresight_enable_link()
186 ret = link_ops(csdev)->enable(csdev, inport, outport); in coresight_enable_link()
192 csdev->enable = true; in coresight_enable_link()
197 static void coresight_disable_link(struct coresight_device *csdev, in coresight_disable_link() argument
208 inport = coresight_find_link_inport(csdev, parent); in coresight_disable_link()
209 outport = coresight_find_link_outport(csdev, child); in coresight_disable_link()
210 link_subtype = csdev->subtype.link_subtype; in coresight_disable_link()
214 nr_conns = csdev->nr_inport; in coresight_disable_link()
217 nr_conns = csdev->nr_outport; in coresight_disable_link()
223 if (atomic_dec_return(&csdev->refcnt[refport]) == 0) { in coresight_disable_link()
224 if (link_ops(csdev)->disable) in coresight_disable_link()
225 link_ops(csdev)->disable(csdev, inport, outport); in coresight_disable_link()
229 if (atomic_read(&csdev->refcnt[i]) != 0) in coresight_disable_link()
232 csdev->enable = false; in coresight_disable_link()
235 static int coresight_enable_source(struct coresight_device *csdev, u32 mode) in coresight_enable_source() argument
239 if (!coresight_source_is_unique(csdev)) { in coresight_enable_source()
240 dev_warn(&csdev->dev, "traceID %d not unique\n", in coresight_enable_source()
241 source_ops(csdev)->trace_id(csdev)); in coresight_enable_source()
245 if (!csdev->enable) { in coresight_enable_source()
246 if (source_ops(csdev)->enable) { in coresight_enable_source()
247 ret = source_ops(csdev)->enable(csdev, NULL, mode); in coresight_enable_source()
251 csdev->enable = true; in coresight_enable_source()
254 atomic_inc(csdev->refcnt); in coresight_enable_source()
267 static bool coresight_disable_source(struct coresight_device *csdev) in coresight_disable_source() argument
269 if (atomic_dec_return(csdev->refcnt) == 0) { in coresight_disable_source()
270 if (source_ops(csdev)->disable) in coresight_disable_source()
271 source_ops(csdev)->disable(csdev, NULL); in coresight_disable_source()
272 csdev->enable = false; in coresight_disable_source()
274 return !csdev->enable; in coresight_disable_source()
281 struct coresight_device *csdev, *parent, *child; in coresight_disable_path() local
284 csdev = nd->csdev; in coresight_disable_path()
285 type = csdev->type; in coresight_disable_path()
294 type = (csdev == coresight_get_sink(path)) ? in coresight_disable_path()
300 coresight_disable_sink(csdev); in coresight_disable_path()
306 parent = list_prev_entry(nd, link)->csdev; in coresight_disable_path()
307 child = list_next_entry(nd, link)->csdev; in coresight_disable_path()
308 coresight_disable_link(csdev, parent, child); in coresight_disable_path()
322 struct coresight_device *csdev, *parent, *child; in coresight_enable_path() local
325 csdev = nd->csdev; in coresight_enable_path()
326 type = csdev->type; in coresight_enable_path()
335 type = (csdev == coresight_get_sink(path)) ? in coresight_enable_path()
341 ret = coresight_enable_sink(csdev, mode); in coresight_enable_path()
349 parent = list_prev_entry(nd, link)->csdev; in coresight_enable_path()
350 child = list_next_entry(nd, link)->csdev; in coresight_enable_path()
351 ret = coresight_enable_link(csdev, parent, child); in coresight_enable_path()
369 struct coresight_device *csdev; in coresight_get_sink() local
374 csdev = list_last_entry(path, struct coresight_node, link)->csdev; in coresight_get_sink()
375 if (csdev->type != CORESIGHT_DEV_TYPE_SINK && in coresight_get_sink()
376 csdev->type != CORESIGHT_DEV_TYPE_LINKSINK) in coresight_get_sink()
379 return csdev; in coresight_get_sink()
385 struct coresight_device *csdev = to_coresight_device(dev); in coresight_enabled_sink() local
387 if ((csdev->type == CORESIGHT_DEV_TYPE_SINK || in coresight_enabled_sink()
388 csdev->type == CORESIGHT_DEV_TYPE_LINKSINK) && in coresight_enabled_sink()
389 csdev->activated) { in coresight_enabled_sink()
398 csdev->activated = false; in coresight_enabled_sink()
434 static void coresight_grab_device(struct coresight_device *csdev) in coresight_grab_device() argument
438 for (i = 0; i < csdev->nr_outport; i++) { in coresight_grab_device()
439 struct coresight_device *child = csdev->conns[i].child_dev; in coresight_grab_device()
444 pm_runtime_get_sync(csdev->dev.parent); in coresight_grab_device()
451 static void coresight_drop_device(struct coresight_device *csdev) in coresight_drop_device() argument
455 pm_runtime_put(csdev->dev.parent); in coresight_drop_device()
456 for (i = 0; i < csdev->nr_outport; i++) { in coresight_drop_device()
457 struct coresight_device *child = csdev->conns[i].child_dev; in coresight_drop_device()
475 static int _coresight_build_path(struct coresight_device *csdev, in _coresight_build_path() argument
484 if (csdev == sink) in _coresight_build_path()
488 for (i = 0; i < csdev->nr_outport; i++) { in _coresight_build_path()
489 struct coresight_device *child_dev = csdev->conns[i].child_dev; in _coresight_build_path()
512 coresight_grab_device(csdev); in _coresight_build_path()
513 node->csdev = csdev; in _coresight_build_path()
552 struct coresight_device *csdev; in coresight_release_path() local
556 csdev = nd->csdev; in coresight_release_path()
558 coresight_drop_device(csdev); in coresight_release_path()
573 static int coresight_validate_source(struct coresight_device *csdev, in coresight_validate_source() argument
578 type = csdev->type; in coresight_validate_source()
579 subtype = csdev->subtype.source_subtype; in coresight_validate_source()
582 dev_err(&csdev->dev, "wrong device type in %s\n", function); in coresight_validate_source()
588 dev_err(&csdev->dev, "wrong device subtype in %s\n", function); in coresight_validate_source()
595 int coresight_enable(struct coresight_device *csdev) in coresight_enable() argument
602 subtype = csdev->subtype.source_subtype; in coresight_enable()
606 ret = coresight_validate_source(csdev, __func__); in coresight_enable()
610 if (csdev->enable) { in coresight_enable()
617 atomic_inc(csdev->refcnt); in coresight_enable()
631 path = coresight_build_path(csdev, sink); in coresight_enable()
642 ret = coresight_enable_source(csdev, CS_MODE_SYSFS); in coresight_enable()
655 cpu = source_ops(csdev)->cpu_id(csdev); in coresight_enable()
679 void coresight_disable(struct coresight_device *csdev) in coresight_disable() argument
686 ret = coresight_validate_source(csdev, __func__); in coresight_disable()
690 if (!csdev->enable || !coresight_disable_source(csdev)) in coresight_disable()
693 switch (csdev->subtype.source_subtype) { in coresight_disable()
695 cpu = source_ops(csdev)->cpu_id(csdev); in coresight_disable()
719 struct coresight_device *csdev = to_coresight_device(dev); in enable_sink_show() local
721 return scnprintf(buf, PAGE_SIZE, "%u\n", csdev->activated); in enable_sink_show()
730 struct coresight_device *csdev = to_coresight_device(dev); in enable_sink_store() local
737 csdev->activated = true; in enable_sink_store()
739 csdev->activated = false; in enable_sink_store()
749 struct coresight_device *csdev = to_coresight_device(dev); in enable_source_show() local
751 return scnprintf(buf, PAGE_SIZE, "%u\n", csdev->enable); in enable_source_show()
760 struct coresight_device *csdev = to_coresight_device(dev); in enable_source_store() local
767 ret = coresight_enable(csdev); in enable_source_store()
771 coresight_disable(csdev); in enable_source_store()
816 struct coresight_device *csdev = to_coresight_device(dev); in coresight_device_release() local
818 kfree(csdev->conns); in coresight_device_release()
819 kfree(csdev->refcnt); in coresight_device_release()
820 kfree(csdev); in coresight_device_release()
827 struct coresight_device *csdev, *i_csdev; in coresight_orphan_match() local
830 csdev = data; in coresight_orphan_match()
834 if (csdev == i_csdev) in coresight_orphan_match()
851 !strcmp(dev_name(&csdev->dev), conn->child_name)) { in coresight_orphan_match()
852 conn->child_dev = csdev; in coresight_orphan_match()
869 static void coresight_fixup_orphan_conns(struct coresight_device *csdev) in coresight_fixup_orphan_conns() argument
876 csdev, coresight_orphan_match); in coresight_fixup_orphan_conns()
880 static void coresight_fixup_device_conns(struct coresight_device *csdev) in coresight_fixup_device_conns() argument
884 for (i = 0; i < csdev->nr_outport; i++) { in coresight_fixup_device_conns()
885 struct coresight_connection *conn = &csdev->conns[i]; in coresight_fixup_device_conns()
896 csdev->orphan = true; in coresight_fixup_device_conns()
905 struct coresight_device *csdev, *iterator; in coresight_remove_match() local
908 csdev = data; in coresight_remove_match()
912 if (csdev == iterator) in coresight_remove_match()
925 if (!strcmp(dev_name(&csdev->dev), conn->child_name)) { in coresight_remove_match()
940 static void coresight_remove_conns(struct coresight_device *csdev) in coresight_remove_conns() argument
943 csdev, coresight_remove_match); in coresight_remove_conns()
1003 struct coresight_device *csdev; in coresight_register() local
1006 csdev = kzalloc(sizeof(*csdev), GFP_KERNEL); in coresight_register()
1007 if (!csdev) { in coresight_register()
1028 csdev->refcnt = refcnts; in coresight_register()
1030 csdev->nr_inport = desc->pdata->nr_inport; in coresight_register()
1031 csdev->nr_outport = desc->pdata->nr_outport; in coresight_register()
1034 if (csdev->nr_outport) { in coresight_register()
1035 conns = kcalloc(csdev->nr_outport, sizeof(*conns), GFP_KERNEL); in coresight_register()
1041 for (i = 0; i < csdev->nr_outport; i++) { in coresight_register()
1048 csdev->conns = conns; in coresight_register()
1050 csdev->type = desc->type; in coresight_register()
1051 csdev->subtype = desc->subtype; in coresight_register()
1052 csdev->ops = desc->ops; in coresight_register()
1053 csdev->orphan = false; in coresight_register()
1055 csdev->dev.type = &coresight_dev_type[desc->type]; in coresight_register()
1056 csdev->dev.groups = desc->groups; in coresight_register()
1057 csdev->dev.parent = desc->dev; in coresight_register()
1058 csdev->dev.release = coresight_device_release; in coresight_register()
1059 csdev->dev.bus = &coresight_bustype; in coresight_register()
1060 dev_set_name(&csdev->dev, "%s", desc->pdata->name); in coresight_register()
1062 ret = device_register(&csdev->dev); in coresight_register()
1064 put_device(&csdev->dev); in coresight_register()
1070 coresight_fixup_device_conns(csdev); in coresight_register()
1071 coresight_fixup_orphan_conns(csdev); in coresight_register()
1075 return csdev; in coresight_register()
1080 kfree(csdev); in coresight_register()
1086 void coresight_unregister(struct coresight_device *csdev) in coresight_unregister() argument
1089 coresight_remove_conns(csdev); in coresight_unregister()
1090 device_unregister(&csdev->dev); in coresight_unregister()