blob: 44824b998498bdebf4719f71ac3949e3d5c29538 [file] [log] [blame]
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +01001/*
2 * Copyright (c) 2016, Intel Corporation
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the Intel Corporation nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
20 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE.
27 *
28 * Author: Liam Girdwood <liam.r.girdwood@linux.intel.com>
29 * Keyon Jie <yang.jie@linux.intel.com>
30 */
31
32#ifndef __INCLUDE_TRACE__
33#define __INCLUDE_TRACE__
34
35#include <stdint.h>
36#include <stdlib.h>
Liam Girdwood71a35c32017-08-09 17:48:50 +010037#include <reef/reef.h>
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010038#include <reef/mailbox.h>
39#include <reef/debug.h>
40#include <reef/timer.h>
41#include <platform/platform.h>
42#include <platform/timer.h>
43
Rander Wang9b34b4d2018-01-23 14:15:52 +000044/* bootloader trace values */
45#define TRACE_BOOT_LDR_ENTRY 0x100
46#define TRACE_BOOT_LDR_HPSRAM 0x110
47#define TRACE_BOOT_LDR_MANIFEST 0x120
48#define TRACE_BOOT_LDR_JUMP 0x150
Liam Girdwood2104ff82018-01-23 14:00:26 +000049
Pierre-Louis Bossartf9458092017-11-09 15:24:07 -060050/* general trace init codes - only used at boot when main trace is not available */
Liam Girdwood2104ff82018-01-23 14:00:26 +000051#define TRACE_BOOT_START 0x1000
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010052#define TRACE_BOOT_ARCH 0x2000
Liam Girdwood2104ff82018-01-23 14:00:26 +000053#define TRACE_BOOT_SYS 0x3000
54#define TRACE_BOOT_PLATFORM 0x4000
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010055
56/* system specific codes */
57#define TRACE_BOOT_SYS_WORK (TRACE_BOOT_SYS + 0x100)
Liam Girdwoodd65a18a2017-06-06 16:37:05 +010058#define TRACE_BOOT_SYS_CPU_FREQ (TRACE_BOOT_SYS + 0x200)
59#define TRACE_BOOT_SYS_HEAP (TRACE_BOOT_SYS + 0x300)
60#define TRACE_BOOT_SYS_NOTE (TRACE_BOOT_SYS + 0x400)
61#define TRACE_BOOT_SYS_SCHED (TRACE_BOOT_SYS + 0x500)
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010062
63/* platform/device specific codes */
Liam Girdwood2104ff82018-01-23 14:00:26 +000064#define TRACE_BOOT_PLATFORM_ENTRY (TRACE_BOOT_PLATFORM + 0x100)
65#define TRACE_BOOT_PLATFORM_MBOX (TRACE_BOOT_PLATFORM + 0x110)
66#define TRACE_BOOT_PLATFORM_SHIM (TRACE_BOOT_PLATFORM + 0x120)
67#define TRACE_BOOT_PLATFORM_PMC (TRACE_BOOT_PLATFORM + 0x130)
68#define TRACE_BOOT_PLATFORM_TIMER (TRACE_BOOT_PLATFORM + 0x140)
69#define TRACE_BOOT_PLATFORM_CLOCK (TRACE_BOOT_PLATFORM + 0x150)
70#define TRACE_BOOT_PLATFORM_SSP_FREQ (TRACE_BOOT_PLATFORM + 0x160)
71#define TRACE_BOOT_PLATFORM_IPC (TRACE_BOOT_PLATFORM + 0x170)
72#define TRACE_BOOT_PLATFORM_DMA (TRACE_BOOT_PLATFORM + 0x180)
73#define TRACE_BOOT_PLATFORM_SSP (TRACE_BOOT_PLATFORM + 0x190)
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010074
75
76/* trace event classes - high 8 bits*/
77#define TRACE_CLASS_IRQ (1 << 24)
78#define TRACE_CLASS_IPC (2 << 24)
79#define TRACE_CLASS_PIPE (3 << 24)
80#define TRACE_CLASS_HOST (4 << 24)
81#define TRACE_CLASS_DAI (5 << 24)
82#define TRACE_CLASS_DMA (6 << 24)
83#define TRACE_CLASS_SSP (7 << 24)
84#define TRACE_CLASS_COMP (8 << 24)
85#define TRACE_CLASS_WAIT (9 << 24)
86#define TRACE_CLASS_LOCK (10 << 24)
87#define TRACE_CLASS_MEM (11 << 24)
88#define TRACE_CLASS_MIXER (12 << 24)
Liam Girdwoodd65a18a2017-06-06 16:37:05 +010089#define TRACE_CLASS_BUFFER (13 << 24)
90#define TRACE_CLASS_VOLUME (14 << 24)
91#define TRACE_CLASS_SWITCH (15 << 24)
92#define TRACE_CLASS_MUX (16 << 24)
Seppo Ingalsuo6a274832017-06-07 14:17:55 +030093#define TRACE_CLASS_SRC (17 << 24)
Seppo Ingalsuo29566ee2017-06-07 14:17:56 +030094#define TRACE_CLASS_TONE (18 << 24)
Seppo Ingalsuo6f03aa52017-06-07 14:17:57 +030095#define TRACE_CLASS_EQ_FIR (19 << 24)
Seppo Ingalsuo6a24a292017-06-07 14:17:58 +030096#define TRACE_CLASS_EQ_IIR (20 << 24)
Liam Girdwoodd163f6d2017-12-21 17:12:50 +000097#define TRACE_CLASS_SA (21 << 24)
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +010098
99/* move to config.h */
100#define TRACE 1
101#define TRACEV 0
102#define TRACEE 1
103
104void _trace_event(uint32_t event);
Yan Wang58e952d2017-10-12 16:35:36 +0800105void _trace_error(uint32_t event);
Ranjani Sridharan210989d2018-03-25 17:34:04 -0700106void _trace_error_value(uint32_t event);
Liam Girdwood3dca7b72017-10-19 17:18:34 +0100107void _trace_event_atomic(uint32_t event);
108void _trace_error_atomic(uint32_t event);
Ranjani Sridharancb1fc872018-03-27 22:07:17 -0700109void trace_flush(void);
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +0100110void trace_off(void);
Liam Girdwood71a35c32017-08-09 17:48:50 +0100111void trace_init(struct reef * reef);
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +0100112
113#if TRACE
114
115#define trace_event(__c, __e) \
116 _trace_event(__c | (__e[0] << 16) | (__e[1] <<8) | __e[2])
Liam Girdwood3dca7b72017-10-19 17:18:34 +0100117#define trace_event_atomic(__c, __e) \
118 _trace_event_atomic(__c | (__e[0] << 16) | (__e[1] <<8) | __e[2])
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +0100119
120#define trace_value(x) _trace_event(x)
Liam Girdwood3dca7b72017-10-19 17:18:34 +0100121#define trace_value_atomic(x) _trace_event_atomic(x)
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +0100122
123#define trace_point(x) platform_trace_point(x)
124
125/* verbose tracing */
126#if TRACEV
127#define tracev_event(__c, __e) trace_event(__c, __e)
128#define tracev_value(x) _trace_event(x)
Liam Girdwood3dca7b72017-10-19 17:18:34 +0100129#define tracev_event_atomic(__c, __e) trace_event_atomic(__c, __e)
130#define tracev_value_atomic(x) _trace_event_atomic(x)
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +0100131#else
132#define tracev_event(__c, __e)
133#define tracev_value(x)
Liam Girdwood3dca7b72017-10-19 17:18:34 +0100134#define tracev_event_atomic(__c, __e)
135#define tracev_value_atomic(x)
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +0100136#endif
137
138/* error tracing */
139#if TRACEE
Yan Wang58e952d2017-10-12 16:35:36 +0800140#define trace_error(__c, __e) \
Yan Wang93086792017-12-06 15:05:28 +0800141 _trace_error_atomic(__c | (__e[0] << 16) | (__e[1] <<8) | __e[2])
Liam Girdwood3dca7b72017-10-19 17:18:34 +0100142#define trace_error_atomic(__c, __e) \
143 _trace_error_atomic(__c | (__e[0] << 16) | (__e[1] <<8) | __e[2])
Ranjani Sridharan210989d2018-03-25 17:34:04 -0700144/* write back error value to mbox*/
145#define trace_error_value(x) _trace_error_atomic(x)
146#define trace_error_value_atomic(x) _trace_error_atomic(x)
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +0100147#else
148#define trace_error(__c, __e)
Liam Girdwood3dca7b72017-10-19 17:18:34 +0100149#define trace_error_atomic(__c, __e)
Ranjani Sridharan210989d2018-03-25 17:34:04 -0700150#define trace_error_value(x)
151#define trace_error_value_atomic(x)
Liam Girdwoodc0dfb4e2016-09-21 15:57:22 +0100152#endif
153
154#else
155
156#define trace_event(x, e)
157#define trace_error(c, e)
158#define trace_value(x)
159#define trace_point(x)
160#define tracev_event(__c, __e)
161#define tracev_value(x)
162
163#endif
164
165#endif