summaryrefslogtreecommitdiff
path: root/drivers/rkflash/rkflash_debug.h
blob: edd609c071d3aa7e5f27ece6cd76cde541150b94 (plain)
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
/* SPDX-License-Identifier: GPL-2.0 */

/* Copyright (c) 2018 Rockchip Electronics Co. Ltd. */

#ifndef _RKFLASH_DEBUG_H
#define _RKFLASH_DEBUG_H

#include <linux/kernel.h>

/*
 * Debug control center
 * 1. Set Printing-adding-macro to 1 to allow print code being compiled in.
 * 2. Set variable 'rkflash_debug' to control debug print to enable print.
 */

/*
 * Printing-adding
 */
extern unsigned int rkflash_debug;

#define	PRINT_SWI_SFC_I		1
#define	PRINT_SWI_SFC_E		1
#define PRINT_SWI_SFC_HEX	1

#define	PRINT_SWI_NANDC_I	1
#define	PRINT_SWI_NANDC_E	1
#define PRINT_SWI_NANDC_HEX	1

/*
 * Print switch, set var rkflash_debug corresponding bit to
 * 1 if needed.
 * I - info
 * E - error
 * HEX - multiline print
 */
#define	PRINT_BIT_SFC_I		BIT(0)
#define	PRINT_BIT_SFC_E		BIT(1)
#define PRINT_BIT_SFC_HEX	BIT(2)
#define	PRINT_BIT_SFC\
		(PRINT_BIT_SFC_E | PRINT_BIT_SFC_HEX)

#define	PRINT_BIT_NANDC_I	BIT(4)
#define	PRINT_BIT_NANDC_E	BIT(5)
#define PRINT_BIT_NANDC_HEX	BIT(5)
#define	PRINT_BIT_NANDC\
		(PRINT_BIT_NANDC_E | PRINT_BIT_NANDC_HEX)

#if (PRINT_SWI_SFC_I)
#define PRINT_SFC_I(...) {if (rkflash_debug & PRINT_BIT_SFC_I)\
				pr_info(__VA_ARGS__); }
#else
#define PRINT_SFC_I(...)
#endif

#if (PRINT_SWI_SFC_E)
#define PRINT_SFC_E(...) {if (rkflash_debug & PRINT_BIT_SFC_E)\
				pr_info(__VA_ARGS__); }
#else
#define PRINT_SFC_E(...)
#endif

#if (PRINT_SWI_SFC_HEX)
#define PRINT_SFC_HEX(s, buf, width, len)\
		rkflash_print_hex(s, buf, width, len)
#else
#define PRINT_SFC_HEX(s, buf, width, len)
#endif

#if (PRINT_SWI_NANDC_I)
#define PRINT_NANDC_I(...) {if (rkflash_debug & PRINT_BIT_NANDC_I)\
				pr_info(__VA_ARGS__); }
#else
#define PRINT_NANDC_I(...)
#endif

#if (PRINT_SWI_NANDC_E)
#define PRINT_NANDC_E(...) {if (rkflash_debug & PRINT_BIT_NANDC_E)\
				pr_info(__VA_ARGS__); }
#else
#define PRINT_NANDC_E(...)
#endif

#if (PRINT_SWI_NANDC_HEX)
#define PRINT_NANDC_HEX(s, buf, width, len)\
		(rkflash_print_hex(s, buf, width, len))
#else
#define PRINT_NANDC_HEX(s, buf, width, len)
#endif

#define rkflash_print_hex(s, buf, w, len)\
		print_hex_dump(KERN_WARNING, s, DUMP_PREFIX_OFFSET,\
			       4, w, buf, (len) * w, 0)

#endif