blob: 76908f54799e0710151d40bee54bc5a000d6f009 [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>
37#include <reef/mailbox.h>
38#include <reef/debug.h>
39#include <reef/timer.h>
40#include <platform/platform.h>
41#include <platform/timer.h>
42
43/* general trace init codes - only used at boot when main trace is not availble */
44#define TRACE_BOOT_START 0x1000
45#define TRACE_BOOT_ARCH 0x2000
46#define TRACE_BOOT_SYS 0x3000
47#define TRACE_BOOT_PLATFORM 0x4000
48
49/* system specific codes */
50#define TRACE_BOOT_SYS_WORK (TRACE_BOOT_SYS + 0x100)
51#define TRACE_BOOT_SYS_CPU_FREQ (TRACE_BOOT_SYS + 0x101)
52
53/* platform/device specific codes */
54#define TRACE_BOOT_PLATFORM_MBOX (TRACE_BOOT_PLATFORM + 0x100)
55#define TRACE_BOOT_PLATFORM_SHIM (TRACE_BOOT_PLATFORM + 0x101)
56#define TRACE_BOOT_PLATFORM_PMC (TRACE_BOOT_PLATFORM + 0x102)
57#define TRACE_BOOT_PLATFORM_TIMER (TRACE_BOOT_PLATFORM + 0x103)
58#define TRACE_BOOT_PLATFORM_CLOCK (TRACE_BOOT_PLATFORM + 0x104)
59#define TRACE_BOOT_PLATFORM_SSP_FREQ (TRACE_BOOT_PLATFORM + 0x105)
60#define TRACE_BOOT_PLATFORM_IPC (TRACE_BOOT_PLATFORM + 0x106)
61#define TRACE_BOOT_PLATFORM_DMA (TRACE_BOOT_PLATFORM + 0x107)
62#define TRACE_BOOT_PLATFORM_SSP (TRACE_BOOT_PLATFORM + 0x108)
63
64
65/* trace event classes - high 8 bits*/
66#define TRACE_CLASS_IRQ (1 << 24)
67#define TRACE_CLASS_IPC (2 << 24)
68#define TRACE_CLASS_PIPE (3 << 24)
69#define TRACE_CLASS_HOST (4 << 24)
70#define TRACE_CLASS_DAI (5 << 24)
71#define TRACE_CLASS_DMA (6 << 24)
72#define TRACE_CLASS_SSP (7 << 24)
73#define TRACE_CLASS_COMP (8 << 24)
74#define TRACE_CLASS_WAIT (9 << 24)
75#define TRACE_CLASS_LOCK (10 << 24)
76#define TRACE_CLASS_MEM (11 << 24)
77#define TRACE_CLASS_MIXER (12 << 24)
78
79/* move to config.h */
80#define TRACE 1
81#define TRACEV 0
82#define TRACEE 1
83
84void _trace_event(uint32_t event);
85void trace_off(void);
86
87#if TRACE
88
89#define trace_event(__c, __e) \
90 _trace_event(__c | (__e[0] << 16) | (__e[1] <<8) | __e[2])
91
92#define trace_value(x) _trace_event(x)
93
94#define trace_point(x) platform_trace_point(x)
95
96/* verbose tracing */
97#if TRACEV
98#define tracev_event(__c, __e) trace_event(__c, __e)
99#define tracev_value(x) _trace_event(x)
100#else
101#define tracev_event(__c, __e)
102#define tracev_value(x)
103#endif
104
105/* error tracing */
106#if TRACEE
107#define trace_error(__c, __e) trace_event(__c, __e)
108#else
109#define trace_error(__c, __e)
110#endif
111
112#else
113
114#define trace_event(x, e)
115#define trace_error(c, e)
116#define trace_value(x)
117#define trace_point(x)
118#define tracev_event(__c, __e)
119#define tracev_value(x)
120
121#endif
122
123#endif