1 /* 2 * Sunxi SD/MMC host driver 3 * 4 * Copyright (C) 2015 AllWinnertech Ltd. 5 * Author: lixiang <lixiang@allwinnertech> 6 * 7 * This program is free software; you can redistribute it and/or modify 8 * it under the terms of the GNU General Public License version 2 as 9 * published by the Free Software Foundation. 10 * 11 * This program is distributed "as is" WITHOUT ANY WARRANTY of any 12 * kind, whether express or implied; without even the implied warranty 13 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 */ 16 17 #ifndef __SUNXI_MMC_DEBUG_H__ 18 #define __SUNXI_MMC_DEBUG_H__ 19 #include <linux/clk.h> 20 #include <linux/reset/sunxi.h> 21 22 #include <linux/gpio.h> 23 #include <linux/platform_device.h> 24 #include <linux/spinlock.h> 25 #include <linux/scatterlist.h> 26 #include <linux/dma-mapping.h> 27 #include <linux/slab.h> 28 #include <linux/reset.h> 29 30 #include <linux/of_address.h> 31 #include <linux/of_gpio.h> 32 #include <linux/of_platform.h> 33 34 35 void sunxi_mmc_dumphex32(struct sunxi_mmc_host *host, char *name, char *base, 36 int len); 37 void sunxi_mmc_dump_des(struct sunxi_mmc_host *host, char *base, int len); 38 39 int sunxi_mmc_uperf_stat(struct sunxi_mmc_host *host, 40 struct mmc_data *data, 41 struct mmc_request *mrq_busy, 42 bool bhalf); 43 44 int mmc_create_sys_fs(struct sunxi_mmc_host *host, 45 struct platform_device *pdev); 46 void mmc_remove_sys_fs(struct sunxi_mmc_host *host, 47 struct platform_device *pdev); 48 void sunxi_dump_reg(struct mmc_host *mmc); 49 int sunxi_remap_readl(resource_size_t phy_addr, u32 *pval); 50 int sunxi_remap_writel(resource_size_t phy_addr, u32 val); 51 52 53 //#define CONFIG_AW_MMC_DEBUG 54 55 #ifdef CONFIG_AW_MMC_DEBUG 56 57 #define SM_DEBUG_WARN BIT(0) 58 #define SM_DEBUG_INFO BIT(1) 59 #define SM_DEBUG_DBG BIT(2) 60 61 62 #define SM_MSG(___mh, ___mpd, ...) do {___mh = ___mh; dev_err(&___mpd->dev, __VA_ARGS__); } while (0) 63 #define SM_MORE(___md, ___mpd, ...) do {dev_err(&___mpd->dev, __VA_ARGS__);\ 64 dev_err(&___mpd->dev, ":%s(L%d)", __FUNCTION__, __LINE__); \ 65 } while (0) 66 67 #define SM_ERR(___d, ...) do { struct platform_device *___pd = to_platform_device(___d);\ 68 struct mmc_host *___m = platform_get_drvdata(___pd);\ 69 struct sunxi_mmc_host *___h = mmc_priv(___m);\ 70 SM_MSG(___h, ___pd, "[E]"__VA_ARGS__); \ 71 } while (0) 72 73 #define SM_WARN(___d, ...) do { struct platform_device *___pd = to_platform_device(___d);\ 74 struct mmc_host *___m = platform_get_drvdata(___pd);\ 75 struct sunxi_mmc_host *___h = mmc_priv(___m);\ 76 if ((___h)->debuglevel & SM_DEBUG_WARN) \ 77 SM_MSG(___h, ___pd, "[W]"__VA_ARGS__); } while (0) 78 79 #define SM_INFO(___d, ...) do { struct platform_device *___pd = to_platform_device(___d);\ 80 struct mmc_host *___m = platform_get_drvdata(___pd);\ 81 struct sunxi_mmc_host *___h = mmc_priv(___m);\ 82 if ((___h)->debuglevel & SM_DEBUG_INFO) \ 83 SM_MSG(___h, ___pd, "[I]"__VA_ARGS__); } while (0) 84 #define SM_DBG(___d, ...) do { struct platform_device *___pd = to_platform_device(___d);\ 85 struct mmc_host *___m = platform_get_drvdata(___pd);\ 86 struct sunxi_mmc_host *___h = mmc_priv(___m);\ 87 if ((___h)->debuglevel & SM_DEBUG_DBG) \ 88 SM_MORE(___h, ___pd, "[D]"__VA_ARGS__); } while (0) 89 #else 90 #define SM_ERR dev_err 91 #define SM_WARN dev_warn 92 #define SM_INFO dev_info 93 #define SM_DBG dev_dbg 94 #endif 95 96 97 #endif 98