UPSTREAM: mmc: dw_mmc: change the DW_MCI_FREQ_MIN from 400K to 100K
[firefly-linux-kernel-4.4.55.git] / drivers / mmc / host / rk_sdmmc_dbg.h
1 /*
2  * Synopsys DesignWare Multimedia Card Interface driver
3  *
4  * Copyright (C) 2014 Fuzhou Rockchip Electronics Co.Ltd.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  */
11  
12 #ifndef __RK_SDMMC_DBG_H
13 #define __RK_SDMMC_DBG_H
14
15 #include <linux/of_gpio.h>
16 #include <linux/of_i2c.h>
17 #include <linux/types.h>
18 #include <linux/bitops.h>
19
20
21 #define DRIVER_NAME "rk_sdmmc"
22 #define DRIVER_PREFIX DRIVER_NAME ": "
23 #define DRIVER_VER  "Dw-mci-rockchip"
24
25 enum MMC_DBG_MASK{
26      MMC_DBG_NONE = 0,
27      MMC_DBG_BOOT = BIT(0),    
28      MMC_DBG_ERROR= BIT(1), 
29      MMC_DBG_WARN = BIT(2),
30      MMC_DBG_INFO = BIT(3),
31      MMC_DBG_CMD  = BIT(4),
32      MMC_DBG_DBG  = BIT(5),
33      MMC_DBG_SW_VOL  = BIT(6),
34      MMC_DBG_ALL  = 0xFF,
35      
36 };
37
38 extern u32 mmc_debug_level;
39 extern char dbg_flag[];
40
41 #define MMC_DBG_FUNC_CONFIG 1
42 #if MMC_DBG_FUNC_CONFIG
43 #define MMC_DBG_BOOT_FUNC(mmc_host,fmt, arg...) \
44     do { \
45         if(mmc_debug_level & MMC_DBG_BOOT) { \
46             if(NULL != strpbrk(dbg_flag,mmc_hostname(mmc_host))) { \
47                 printk(DRIVER_PREFIX "BOOT " fmt "\n", ##arg);\
48             } \
49         } \
50     }while(0)
51 #define MMC_DBG_ERR_FUNC(mmc_host,fmt, arg...) \
52     do{ \
53         if(mmc_debug_level & MMC_DBG_ERROR) { \
54             if(strstr(dbg_flag,mmc_hostname(mmc_host))) { \
55                 printk(DRIVER_PREFIX "ERROR " fmt "\n", ##arg);\
56             } \
57         } \
58     }while(0)
59 #define MMC_DBG_WARN_FUNC(mmc_host,fmt, arg...) \
60     do { \
61         if(mmc_debug_level & MMC_DBG_WARN) { \
62             if(strstr(dbg_flag,mmc_hostname(mmc_host))) { \
63                 printk(DRIVER_PREFIX "WARN " fmt "\n", ##arg);\
64             } \
65         } \
66     }while(0)
67 #define MMC_DBG_INFO_FUNC(mmc_host,fmt, arg...) \
68     do { \
69         if(mmc_debug_level & MMC_DBG_INFO) { \
70             if(strstr(dbg_flag,mmc_hostname(mmc_host))) { \
71                 printk(DRIVER_PREFIX "INFO " fmt "\n", ##arg);\
72             } \
73         } \
74     }while(0)
75 #define MMC_DBG_CMD_FUNC(mmc_host,fmt, arg...) \
76    do { \
77         if(mmc_debug_level & MMC_DBG_CMD) { \
78             if(strstr(dbg_flag,mmc_hostname(mmc_host))) { \
79                 printk(DRIVER_PREFIX "CMD " fmt "\n", ##arg);\
80             } \
81         } \
82     }while(0)
83 #define MMC_DBG_SW_VOL_FUNC(mmc_host,fmt, arg...) \
84    do { \
85         if(mmc_debug_level & MMC_DBG_SW_VOL) { \
86             if(strstr(dbg_flag,mmc_hostname(mmc_host))) { \
87                 printk(DRIVER_PREFIX "SW-VOL " fmt "\n", ##arg);\
88             } \
89         } \
90     }while(0)
91 #else
92 #define MMC_DBG_BOOT_FUNC(mmc_host,fmt, arg...) {printk(DRIVER_PREFIX "BOOT " fmt "\n", ##arg);}
93 #define MMC_DBG_ERR_FUNC(mmc_host,fmt, arg...)
94 #define MMC_DBG_WARN_FUNC(mmc_host,fmt, arg...)
95 #define MMC_DBG_INFO_FUNC(mmc_host,fmt, arg...)
96 #define MMC_DBG_CMD_FUNC(mmc_host,fmt, arg...)
97 #define MMC_DBG_SW_VOL_FUNC(mmc_host,fmt, arg...)
98 #endif
99
100 #if defined(CONFIG_DYNAMIC_DEBUG)
101     #define mmc_debug(level, fmt, arg...) \
102            do { \
103                if (unlikely(level & mmc_debug_level)) \
104                    dynamic_pr_debug(DRIVER_PREFIX fmt "\n", ##arg); \
105            } while (0)
106 #else
107     #define mmc_debug(level, fmt, arg...) \
108            do { \
109                if (unlikely(level & mmc_debug_level)) \
110                    printk(KERN_DEBUG pr_fmt(DRIVER_PREFIX fmt "\n"), \
111                    ##arg); \
112            } while (0)
113 #endif
114
115 #endif