Skip to content
Navigation Menu
Toggle navigation
Sign in
In this repository
All GitHub Enterprise
↵
Jump to
↵
No suggested jump to results
In this repository
All GitHub Enterprise
↵
Jump to
↵
In this organization
All GitHub Enterprise
↵
Jump to
↵
In this repository
All GitHub Enterprise
↵
Jump to
↵
Sign in
Reseting focus
You signed in with another tab or window.
Reload
to refresh your session.
You signed out in another tab or window.
Reload
to refresh your session.
You switched accounts on another tab or window.
Reload
to refresh your session.
Dismiss alert
{{ message }}
mariux64
/
linux
Public
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Issues
2
Pull requests
0
Actions
Projects
0
Wiki
Security
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Wiki
Security
Insights
Files
2ccffaf
Documentation
arch
block
crypto
drivers
accessibility
acpi
amba
android
ata
atm
auxdisplay
base
bcma
block
bluetooth
bus
cdrom
char
clk
clocksource
connector
coresight
Makefile
coresight-etb10.c
coresight-etm-cp14.c
coresight-etm.h
coresight-etm3x.c
coresight-funnel.c
coresight-priv.h
coresight-replicator.c
coresight-tmc.c
coresight-tpiu.c
coresight.c
of_coresight.c
cpufreq
cpuidle
crypto
dca
devfreq
dio
dma-buf
dma
edac
eisa
extcon
firewire
firmware
fmc
gpio
gpu
hid
hsi
hv
hwmon
hwspinlock
i2c
ide
idle
iio
infiniband
input
iommu
ipack
irqchip
isdn
leds
lguest
macintosh
mailbox
mcb
md
media
memory
memstick
message
mfd
misc
mmc
mtd
net
nfc
ntb
nubus
of
oprofile
parisc
parport
pci
pcmcia
phy
pinctrl
platform
pnp
power
powercap
pps
ps3
ptp
pwm
rapidio
ras
regulator
remoteproc
reset
rpmsg
rtc
s390
sbus
scsi
sfi
sh
sn
soc
spi
spmi
ssb
staging
target
tc
thermal
thunderbolt
tty
uio
usb
uwb
vfio
vhost
video
virt
virtio
vlynq
vme
w1
watchdog
xen
zorro
Kconfig
Makefile
firmware
fs
include
init
ipc
kernel
lib
mm
net
samples
scripts
security
sound
tools
usr
virt
.gitignore
.mailmap
COPYING
CREDITS
Kbuild
Kconfig
MAINTAINERS
Makefile
README
REPORTING-BUGS
Breadcrumbs
linux
/
drivers
/
coresight
/
of_coresight.c
Blame
Blame
Latest commit
History
History
204 lines (168 loc) · 4.96 KB
Breadcrumbs
linux
/
drivers
/
coresight
/
of_coresight.c
Top
File metadata and controls
Code
Blame
204 lines (168 loc) · 4.96 KB
Raw
/* Copyright (c) 2012, The Linux Foundation. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 and * only version 2 as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */ #include <linux/module.h> #include <linux/types.h> #include <linux/err.h> #include <linux/slab.h> #include <linux/clk.h> #include <linux/of.h> #include <linux/of_address.h> #include <linux/of_graph.h> #include <linux/of_platform.h> #include <linux/platform_device.h> #include <linux/amba/bus.h> #include <linux/coresight.h> #include <asm/smp_plat.h> static int of_dev_node_match(struct device *dev, void *data) { return dev->of_node == data; } static struct device * of_coresight_get_endpoint_device(struct device_node *endpoint) { struct device *dev = NULL; /* * If we have a non-configuable replicator, it will be found on the * platform bus. */ dev = bus_find_device(&platform_bus_type, NULL, endpoint, of_dev_node_match); if (dev) return dev; /* * We have a configurable component - circle through the AMBA bus * looking for the device that matches the endpoint node. */ return bus_find_device(&amba_bustype, NULL, endpoint, of_dev_node_match); } static struct device_node *of_get_coresight_endpoint( const struct device_node *parent, struct device_node *prev) { struct device_node *node = of_graph_get_next_endpoint(parent, prev); of_node_put(prev); return node; } static void of_coresight_get_ports(struct device_node *node, int *nr_inport, int *nr_outport) { struct device_node *ep = NULL; int in = 0, out = 0; do { ep = of_get_coresight_endpoint(node, ep); if (!ep) break; if (of_property_read_bool(ep, "slave-mode")) in++; else out++; } while (ep); *nr_inport = in; *nr_outport = out; } static int of_coresight_alloc_memory(struct device *dev, struct coresight_platform_data *pdata) { /* List of output port on this component */ pdata->outports = devm_kzalloc(dev, pdata->nr_outport * sizeof(*pdata->outports), GFP_KERNEL); if (!pdata->outports) return -ENOMEM; /* Children connected to this component via @outports */ pdata->child_names = devm_kzalloc(dev, pdata->nr_outport * sizeof(*pdata->child_names), GFP_KERNEL); if (!pdata->child_names) return -ENOMEM; /* Port number on the child this component is connected to */ pdata->child_ports = devm_kzalloc(dev, pdata->nr_outport * sizeof(*pdata->child_ports), GFP_KERNEL); if (!pdata->child_ports) return -ENOMEM; return 0; } struct coresight_platform_data *of_get_coresight_platform_data( struct device *dev, struct device_node *node) { int i = 0, ret = 0; struct coresight_platform_data *pdata; struct of_endpoint endpoint, rendpoint; struct device *rdev; struct device_node *cpu; struct device_node *ep = NULL; struct device_node *rparent = NULL; struct device_node *rport = NULL; pdata = devm_kzalloc(dev, sizeof(*pdata), GFP_KERNEL); if (!pdata) return ERR_PTR(-ENOMEM); /* Use device name as sysfs handle */ pdata->name = dev_name(dev); /* Get the number of input and output port for this component */ of_coresight_get_ports(node, &pdata->nr_inport, &pdata->nr_outport); if (pdata->nr_outport) { ret = of_coresight_alloc_memory(dev, pdata); if (ret) return ERR_PTR(ret); /* Iterate through each port to discover topology */ do { /* Get a handle on a port */ ep = of_get_coresight_endpoint(node, ep); if (!ep) break; /* * No need to deal with input ports, processing for as * processing for output ports will deal with them. */ if (of_find_property(ep, "slave-mode", NULL)) continue; /* Get a handle on the local endpoint */ ret = of_graph_parse_endpoint(ep, &endpoint); if (ret) continue; /* The local out port number */ pdata->outports[i] = endpoint.id; /* * Get a handle on the remote port and parent * attached to it. */ rparent = of_graph_get_remote_port_parent(ep); rport = of_graph_get_remote_port(ep); if (!rparent || !rport) continue; if (of_graph_parse_endpoint(rport, &rendpoint)) continue; rdev = of_coresight_get_endpoint_device(rparent); if (!rdev) continue; pdata->child_names[i] = dev_name(rdev); pdata->child_ports[i] = rendpoint.id; i++; } while (ep); } /* Affinity defaults to CPU0 */ pdata->cpu = 0; cpu = of_parse_phandle(node, "cpu", 0); if (cpu) { const u32 *mpidr; int len, index; mpidr = of_get_property(cpu, "reg", &len); if (mpidr && len == 4) { index = get_logical_index(be32_to_cpup(mpidr)); if (index != -EINVAL) pdata->cpu = index; } } return pdata; } EXPORT_SYMBOL_GPL(of_get_coresight_platform_data);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
You can’t perform that action at this time.