182e0c782SMike Leach.. SPDX-License-Identifier: GPL-2.0 2*7f06a1c9SMauro Carvalho Chehab 382e0c782SMike Leach============================================= 482e0c782SMike LeachCoreSight Embedded Cross Trigger (CTI & CTM). 582e0c782SMike Leach============================================= 682e0c782SMike Leach 782e0c782SMike Leach :Author: Mike Leach <mike.leach@linaro.org> 882e0c782SMike Leach :Date: November 2019 982e0c782SMike Leach 1082e0c782SMike LeachHardware Description 1182e0c782SMike Leach-------------------- 1282e0c782SMike Leach 1382e0c782SMike LeachThe CoreSight Cross Trigger Interface (CTI) is a hardware device that takes 1482e0c782SMike Leachindividual input and output hardware signals known as triggers to and from 1582e0c782SMike Leachdevices and interconnects them via the Cross Trigger Matrix (CTM) to other 1682e0c782SMike Leachdevices via numbered channels, in order to propagate events between devices. 1782e0c782SMike Leach 1882e0c782SMike Leache.g.:: 1982e0c782SMike Leach 2082e0c782SMike Leach 0000000 in_trigs ::::::: 2182e0c782SMike Leach 0 C 0----------->: : +======>(other CTI channel IO) 2282e0c782SMike Leach 0 P 0<-----------: : v 2382e0c782SMike Leach 0 U 0 out_trigs : : Channels ***** ::::::: 2482e0c782SMike Leach 0000000 : CTI :<=========>*CTM*<====>: CTI :---+ 2582e0c782SMike Leach ####### in_trigs : : (id 0-3) ***** ::::::: v 2682e0c782SMike Leach # ETM #----------->: : ^ ####### 2782e0c782SMike Leach # #<-----------: : +---# ETR # 2882e0c782SMike Leach ####### out_trigs ::::::: ####### 2982e0c782SMike Leach 3082e0c782SMike LeachThe CTI driver enables the programming of the CTI to attach triggers to 3182e0c782SMike Leachchannels. When an input trigger becomes active, the attached channel will 3282e0c782SMike Leachbecome active. Any output trigger attached to that channel will also 3382e0c782SMike Leachbecome active. The active channel is propagated to other CTIs via the CTM, 3482e0c782SMike Leachactivating connected output triggers there, unless filtered by the CTI 3582e0c782SMike Leachchannel gate. 3682e0c782SMike Leach 3782e0c782SMike LeachIt is also possible to activate a channel using system software directly 3882e0c782SMike Leachprogramming registers in the CTI. 3982e0c782SMike Leach 4082e0c782SMike LeachThe CTIs are registered by the system to be associated with CPUs and/or other 4182e0c782SMike LeachCoreSight devices on the trace data path. When these devices are enabled the 4282e0c782SMike Leachattached CTIs will also be enabled. By default/on power up the CTIs have 4382e0c782SMike Leachno programmed trigger/channel attachments, so will not affect the system 4482e0c782SMike Leachuntil explicitly programmed. 4582e0c782SMike Leach 4682e0c782SMike LeachThe hardware trigger connections between CTIs and devices is implementation 4782e0c782SMike Leachdefined, unless the CPU/ETM combination is a v8 architecture, in which case 4882e0c782SMike Leachthe connections have an architecturally defined standard layout. 4982e0c782SMike Leach 5082e0c782SMike LeachThe hardware trigger signals can also be connected to non-CoreSight devices 5182e0c782SMike Leach(e.g. UART), or be propagated off chip as hardware IO lines. 5282e0c782SMike Leach 5382e0c782SMike LeachAll the CTI devices are associated with a CTM. On many systems there will be a 5482e0c782SMike Leachsingle effective CTM (one CTM, or multiple CTMs all interconnected), but it is 5582e0c782SMike Leachpossible that systems can have nets of CTIs+CTM that are not interconnected by 5682e0c782SMike Leacha CTM to each other. On these systems a CTM index is declared to associate 5782e0c782SMike LeachCTI devices that are interconnected via a given CTM. 5882e0c782SMike Leach 5982e0c782SMike LeachSysfs files and directories 6082e0c782SMike Leach--------------------------- 6182e0c782SMike Leach 6282e0c782SMike LeachThe CTI devices appear on the existing CoreSight bus alongside the other 6382e0c782SMike LeachCoreSight devices:: 6482e0c782SMike Leach 6582e0c782SMike Leach >$ ls /sys/bus/coresight/devices 6682e0c782SMike Leach cti_cpu0 cti_cpu2 cti_sys0 etm0 etm2 funnel0 replicator0 tmc_etr0 6782e0c782SMike Leach cti_cpu1 cti_cpu3 cti_sys1 etm1 etm3 funnel1 tmc_etf0 tpiu0 6882e0c782SMike Leach 6982e0c782SMike LeachThe ``cti_cpu<N>`` named CTIs are associated with a CPU, and any ETM used by 7082e0c782SMike Leachthat core. The ``cti_sys<N>`` CTIs are general system infrastructure CTIs that 7182e0c782SMike Leachcan be associated with other CoreSight devices, or other system hardware 7282e0c782SMike Leachcapable of generating or using trigger signals.:: 7382e0c782SMike Leach 7482e0c782SMike Leach >$ ls /sys/bus/coresight/devices/etm0/cti_cpu0 7582e0c782SMike Leach channels ctmid enable nr_trigger_cons mgmt power powered regs 765153e57bSMike Leach connections subsystem triggers0 triggers1 uevent 7782e0c782SMike Leach 7882e0c782SMike Leach*Key file items are:-* 7982e0c782SMike Leach * ``enable``: enables/disables the CTI. Read to determine current state. 8082e0c782SMike Leach If this shows as enabled (1), but ``powered`` shows unpowered (0), then 8182e0c782SMike Leach the enable indicates a request to enabled when the device is powered. 8282e0c782SMike Leach * ``ctmid`` : associated CTM - only relevant if system has multiple CTI+CTM 8382e0c782SMike Leach clusters that are not interconnected. 8482e0c782SMike Leach * ``nr_trigger_cons`` : total connections - triggers<N> directories. 8582e0c782SMike Leach * ``powered`` : Read to determine if the CTI is currently powered. 8682e0c782SMike Leach 8782e0c782SMike Leach*Sub-directories:-* 8882e0c782SMike Leach * ``triggers<N>``: contains list of triggers for an individual connection. 8982e0c782SMike Leach * ``channels``: Contains the channel API - CTI main programming interface. 9082e0c782SMike Leach * ``regs``: Gives access to the raw programmable CTI regs. 9182e0c782SMike Leach * ``mgmt``: the standard CoreSight management registers. 925153e57bSMike Leach * ``connections``: Links to connected *CoreSight* devices. The number of 935153e57bSMike Leach links can be 0 to ``nr_trigger_cons``. Actual number given by ``nr_links`` 945153e57bSMike Leach in this directory. 9582e0c782SMike Leach 9682e0c782SMike Leach 9782e0c782SMike Leachtriggers<N> directories 9882e0c782SMike Leach~~~~~~~~~~~~~~~~~~~~~~~ 9982e0c782SMike Leach 10082e0c782SMike LeachIndividual trigger connection information. This describes trigger signals for 10182e0c782SMike LeachCoreSight and non-CoreSight connections. 10282e0c782SMike Leach 10382e0c782SMike LeachEach triggers directory has a set of parameters describing the triggers for 10482e0c782SMike Leachthe connection. 10582e0c782SMike Leach 10682e0c782SMike Leach * ``name`` : name of connection 10782e0c782SMike Leach * ``in_signals`` : input trigger signal indexes used in this connection. 10882e0c782SMike Leach * ``in_types`` : functional types for in signals. 10982e0c782SMike Leach * ``out_signals`` : output trigger signals for this connection. 11082e0c782SMike Leach * ``out_types`` : functional types for out signals. 11182e0c782SMike Leach 11282e0c782SMike Leache.g:: 11382e0c782SMike Leach 11482e0c782SMike Leach >$ ls ./cti_cpu0/triggers0/ 11582e0c782SMike Leach in_signals in_types name out_signals out_types 11682e0c782SMike Leach >$ cat ./cti_cpu0/triggers0/name 11782e0c782SMike Leach cpu0 11882e0c782SMike Leach >$ cat ./cti_cpu0/triggers0/out_signals 11982e0c782SMike Leach 0-2 12082e0c782SMike Leach >$ cat ./cti_cpu0/triggers0/out_types 12182e0c782SMike Leach pe_edbgreq pe_dbgrestart pe_ctiirq 12282e0c782SMike Leach >$ cat ./cti_cpu0/triggers0/in_signals 12382e0c782SMike Leach 0-1 12482e0c782SMike Leach >$ cat ./cti_cpu0/triggers0/in_types 12582e0c782SMike Leach pe_dbgtrigger pe_pmuirq 12682e0c782SMike Leach 12782e0c782SMike LeachIf a connection has zero signals in either the 'in' or 'out' triggers then 12882e0c782SMike Leachthose parameters will be omitted. 12982e0c782SMike Leach 13082e0c782SMike LeachChannels API Directory 13182e0c782SMike Leach~~~~~~~~~~~~~~~~~~~~~~ 13282e0c782SMike Leach 13382e0c782SMike LeachThis provides an easy way to attach triggers to channels, without needing 13482e0c782SMike Leachthe multiple register operations that are required if manipulating the 13582e0c782SMike Leach'regs' sub-directory elements directly. 13682e0c782SMike Leach 13782e0c782SMike LeachA number of files provide this API:: 13882e0c782SMike Leach 13982e0c782SMike Leach >$ ls ./cti_sys0/channels/ 14082e0c782SMike Leach chan_clear chan_inuse chan_xtrigs_out trigin_attach 14182e0c782SMike Leach chan_free chan_pulse chan_xtrigs_reset trigin_detach 14282e0c782SMike Leach chan_gate_disable chan_set chan_xtrigs_sel trigout_attach 14382e0c782SMike Leach chan_gate_enable chan_xtrigs_in trig_filter_enable trigout_detach 14482e0c782SMike Leach trigout_filtered 14582e0c782SMike Leach 14682e0c782SMike LeachMost access to these elements take the form:: 14782e0c782SMike Leach 14882e0c782SMike Leach echo <chan> [<trigger>] > /<device_path>/<operation> 14982e0c782SMike Leach 15082e0c782SMike Leachwhere the optional <trigger> is only needed for trigXX_attach | detach 15182e0c782SMike Leachoperations. 15282e0c782SMike Leach 15382e0c782SMike Leache.g.:: 15482e0c782SMike Leach 15582e0c782SMike Leach >$ echo 0 1 > ./cti_sys0/channels/trigout_attach 15682e0c782SMike Leach >$ echo 0 > ./cti_sys0/channels/chan_set 15782e0c782SMike Leach 15882e0c782SMike LeachAttaches trigout(1) to channel(0), then activates channel(0) generating a 15982e0c782SMike Leachset state on cti_sys0.trigout(1) 16082e0c782SMike Leach 16182e0c782SMike Leach 16282e0c782SMike Leach*API operations* 16382e0c782SMike Leach 16482e0c782SMike Leach * ``trigin_attach, trigout_attach``: Attach a channel to a trigger signal. 16582e0c782SMike Leach * ``trigin_detach, trigout_detach``: Detach a channel from a trigger signal. 16682e0c782SMike Leach * ``chan_set``: Set the channel - the set state will be propagated around 16782e0c782SMike Leach the CTM to other connected devices. 16882e0c782SMike Leach * ``chan_clear``: Clear the channel. 16982e0c782SMike Leach * ``chan_pulse``: Set the channel for a single CoreSight clock cycle. 17082e0c782SMike Leach * ``chan_gate_enable``: Write operation sets the CTI gate to propagate 17182e0c782SMike Leach (enable) the channel to other devices. This operation takes a channel 17282e0c782SMike Leach number. CTI gate is enabled for all channels by default at power up. Read 17382e0c782SMike Leach to list the currently enabled channels on the gate. 17482e0c782SMike Leach * ``chan_gate_disable``: Write channel number to disable gate for that 17582e0c782SMike Leach channel. 17682e0c782SMike Leach * ``chan_inuse``: Show the current channels attached to any signal 17782e0c782SMike Leach * ``chan_free``: Show channels with no attached signals. 17882e0c782SMike Leach * ``chan_xtrigs_sel``: write a channel number to select a channel to view, 17982e0c782SMike Leach read to show the selected channel number. 18082e0c782SMike Leach * ``chan_xtrigs_in``: Read to show the input triggers attached to 18182e0c782SMike Leach the selected view channel. 18282e0c782SMike Leach * ``chan_xtrigs_out``:Read to show the output triggers attached to 18382e0c782SMike Leach the selected view channel. 18482e0c782SMike Leach * ``trig_filter_enable``: Defaults to enabled, disable to allow potentially 18582e0c782SMike Leach dangerous output signals to be set. 18682e0c782SMike Leach * ``trigout_filtered``: Trigger out signals that are prevented from being 18782e0c782SMike Leach set if filtering ``trig_filter_enable`` is enabled. One use is to prevent 18882e0c782SMike Leach accidental ``EDBGREQ`` signals stopping a core. 18982e0c782SMike Leach * ``chan_xtrigs_reset``: Write 1 to clear all channel / trigger programming. 19082e0c782SMike Leach Resets device hardware to default state. 19182e0c782SMike Leach 19282e0c782SMike Leach 19382e0c782SMike LeachThe example below attaches input trigger index 1 to channel 2, and output 19482e0c782SMike Leachtrigger index 6 to the same channel. It then examines the state of the 19582e0c782SMike Leachchannel / trigger connections using the appropriate sysfs attributes. 19682e0c782SMike Leach 19782e0c782SMike LeachThe settings mean that if either input trigger 1, or channel 2 go active then 19882e0c782SMike Leachtrigger out 6 will go active. We then enable the CTI, and use the software 19982e0c782SMike Leachchannel control to activate channel 2. We see the active channel on the 20082e0c782SMike Leach``choutstatus`` register and the active signal on the ``trigoutstatus`` 20182e0c782SMike Leachregister. Finally clearing the channel removes this. 20282e0c782SMike Leach 20382e0c782SMike Leache.g.:: 20482e0c782SMike Leach 20582e0c782SMike Leach .../cti_sys0/channels# echo 2 1 > trigin_attach 20682e0c782SMike Leach .../cti_sys0/channels# echo 2 6 > trigout_attach 20782e0c782SMike Leach .../cti_sys0/channels# cat chan_free 20882e0c782SMike Leach 0-1,3 20982e0c782SMike Leach .../cti_sys0/channels# cat chan_inuse 21082e0c782SMike Leach 2 21182e0c782SMike Leach .../cti_sys0/channels# echo 2 > chan_xtrigs_sel 21282e0c782SMike Leach .../cti_sys0/channels# cat chan_xtrigs_trigin 21382e0c782SMike Leach 1 21482e0c782SMike Leach .../cti_sys0/channels# cat chan_xtrigs_trigout 21582e0c782SMike Leach 6 21682e0c782SMike Leach .../cti_sys0/# echo 1 > enable 21782e0c782SMike Leach .../cti_sys0/channels# echo 2 > chan_set 21882e0c782SMike Leach .../cti_sys0/channels# cat ../regs/choutstatus 21982e0c782SMike Leach 0x4 22082e0c782SMike Leach .../cti_sys0/channels# cat ../regs/trigoutstatus 22182e0c782SMike Leach 0x40 22282e0c782SMike Leach .../cti_sys0/channels# echo 2 > chan_clear 22382e0c782SMike Leach .../cti_sys0/channels# cat ../regs/trigoutstatus 22482e0c782SMike Leach 0x0 22582e0c782SMike Leach .../cti_sys0/channels# cat ../regs/choutstatus 22682e0c782SMike Leach 0x0 227