From 0c421031e2e3e92849fb3c83509f254101e599e4 Mon Sep 17 00:00:00 2001 From: xbw Date: Wed, 5 Mar 2014 17:33:38 +0800 Subject: [PATCH] SDMMC: define the debug log --- drivers/mmc/host/dw_mmc-rockchip.c | 7 +++--- drivers/mmc/host/rk_sdmmc.c | 15 +++++++++--- drivers/mmc/host/rk_sdmmc.h | 2 ++ drivers/mmc/host/rk_sdmmc_of.c | 38 ++++++++++++----------------- drivers/mmc/host/rk_sdmmc_of.h | 39 +++++++++++++++--------------- 5 files changed, 53 insertions(+), 48 deletions(-) diff --git a/drivers/mmc/host/dw_mmc-rockchip.c b/drivers/mmc/host/dw_mmc-rockchip.c index 856bc7ccfc72..279778712053 100755 --- a/drivers/mmc/host/dw_mmc-rockchip.c +++ b/drivers/mmc/host/dw_mmc-rockchip.c @@ -24,7 +24,7 @@ #include "dw_mmc-pltfm.h" #include "rk_sdmmc_of.h" -u32 mmc_debug_level = MMC_DBG_BOOT | MMC_DBG_ERROR;//|MMC_DBG_WARN|MMC_DBG_ALL; +//u32 mmc_debug_level = MMC_DBG_ALL; #define NUM_PINS(x) (x + 2) @@ -117,7 +117,7 @@ static void dw_mci_rockchip_prepare_command(struct dw_mci *host, u32 *cmdr) static void dw_mci_rockchip_set_ios(struct dw_mci *host, struct mmc_ios *ios) { - struct dw_mci_rockchip_priv_data *priv = host->priv; + //struct dw_mci_rockchip_priv_data *priv = host->priv; /* if (ios->timing == MMC_TIMING_UHS_DDR50) mci_writel(host, CLKSEL, priv->ddr_timing); @@ -128,12 +128,13 @@ static void dw_mci_rockchip_set_ios(struct dw_mci *host, struct mmc_ios *ios) static int dw_mci_rockchip_parse_dt(struct dw_mci *host) { +/* struct dw_mci_rockchip_priv_data *priv = host->priv; struct device_node *np = host->dev->of_node; u32 timing[2]; u32 div = 0; int ret; -/*rk set the timing in CRU + //rk set the timing in CRU of_property_read_u32(np, "samsung,dw-mshc-ciu-div", &div); priv->ciu_div = div; diff --git a/drivers/mmc/host/rk_sdmmc.c b/drivers/mmc/host/rk_sdmmc.c index 905ebadfe7d4..88dc97473770 100755 --- a/drivers/mmc/host/rk_sdmmc.c +++ b/drivers/mmc/host/rk_sdmmc.c @@ -54,8 +54,8 @@ #define DW_MCI_RECV_STATUS 2 #define DW_MCI_DMA_THRESHOLD 16 -#define DW_MCI_FREQ_MAX 200000000 /* unit: HZ */ -#define DW_MCI_FREQ_MIN 400000 /* unit: HZ */ +#define DW_MCI_FREQ_MAX 50000000//200000000 /* unit: HZ */ +#define DW_MCI_FREQ_MIN 300000//400000 /* unit: HZ */ #ifdef CONFIG_MMC_DW_IDMAC struct idmac_desc { @@ -2176,15 +2176,24 @@ static int dw_mci_init_slot(struct dw_mci *host, unsigned int id) slot->quirks = dw_mci_of_get_slot_quirks(host->dev, slot->id); mmc->ops = &dw_mci_ops; +#if 0 + mmc->f_min = DIV_ROUND_UP(host->bus_hz, 510); + mmc->f_max = host->bus_hz; +printk("%d..%s: fmin=%d, fmax=%d, bus_hz=%d \n", __LINE__,__FUNCTION__,mmc->f_min, mmc->f_max, host->bus_hz); +#else if (of_property_read_u32_array(host->dev->of_node, "clock-freq-min-max", freq, 2)) { mmc->f_min = DW_MCI_FREQ_MIN; mmc->f_max = DW_MCI_FREQ_MAX; + + printk("%d..%s: fmin=%d, fmax=%d \n", __LINE__,__FUNCTION__,mmc->f_min, mmc->f_max); } else { mmc->f_min = freq[0]; mmc->f_max = freq[1]; + + printk("%d..%s: fmin=%d, fmax=%d \n", __LINE__,__FUNCTION__,mmc->f_min, mmc->f_max); } - +#endif if (host->pdata->get_ocr) mmc->ocr_avail = host->pdata->get_ocr(id); else diff --git a/drivers/mmc/host/rk_sdmmc.h b/drivers/mmc/host/rk_sdmmc.h index 47c60a2b4297..3c98a368d64e 100755 --- a/drivers/mmc/host/rk_sdmmc.h +++ b/drivers/mmc/host/rk_sdmmc.h @@ -5,6 +5,8 @@ * Copyright (C) 2009 NXP Semiconductors * Copyright (C) 2009, 2010 Imagination Technologies Ltd. * + * Copyright (C) 2014 Fuzhou Rockchip Electronics Co.Ltd. + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or diff --git a/drivers/mmc/host/rk_sdmmc_of.c b/drivers/mmc/host/rk_sdmmc_of.c index 522420e5c054..778a50995220 100755 --- a/drivers/mmc/host/rk_sdmmc_of.c +++ b/drivers/mmc/host/rk_sdmmc_of.c @@ -1,30 +1,22 @@ + + #include "rk_sdmmc_of.h" +u32 mmc_debug_level; + static void rockchip_mmc_of_dump(struct rk_sdmmc_of *rk_mmc_property) { -printk("%d..%s: =====test 2014-03-04 ====\n", __LINE__, __FUNCTION__); -//dump_stack(); - - mmc_debug(MMC_DBG_BOOT,"=========rockchip mmc dts dump info start==============\n"); - mmc_debug(MMC_DBG_BOOT,"mmc,caps: 0x%x\n",rk_mmc_property->mmc_caps); - mmc_debug(MMC_DBG_BOOT,"mmc,ocr: 0x%x\n",rk_mmc_property->mmc_ocr); - mmc_debug(MMC_DBG_BOOT,"mmc,int: 0x%x\n",rk_mmc_property->mmc_int_type); - mmc_debug(MMC_DBG_BOOT,"mmc,emmc_is_selected: 0x%x\n",rk_mmc_property->emmc_is_selected); - mmc_debug(MMC_DBG_BOOT,"mmc,use_dma: %d %d\n",rk_mmc_property->mmc_dma_is_used[0], - rk_mmc_property->mmc_dma_is_used[1]); - mmc_debug(MMC_DBG_BOOT,"mmc,dma_ch: %d\n",rk_mmc_property->mmc_dma_chn); - mmc_debug(MMC_DBG_BOOT,"=========rockchip mmc dts dump info end================\n"); - /* - printk("=========rockchip mmc dts dump info start==============\n"); - printk("mmc,caps: 0x%x\n",rk_mmc_property->mmc_caps); - printk("mmc,ocr: 0x%x\n",rk_mmc_property->mmc_ocr); - printk("mmc,int: 0x%x\n",rk_mmc_property->mmc_int_type); - printk("mmc,emmc_is_selected: 0x%x\n",rk_mmc_property->emmc_is_selected); - printk("mmc,use_dma: %d %d\n",rk_mmc_property->mmc_dma_is_used[0], + +printk("%d..%s: ===test ==\n", __LINE__, __FUNCTION__); + MMC_DBG_BOOT_FUNC("=========rockchip mmc dts dump info start== 2014-03-05 16:08 ======\n"); + MMC_DBG_BOOT_FUNC("mmc,caps: 0x%x\n",rk_mmc_property->mmc_caps); + MMC_DBG_BOOT_FUNC("mmc,ocr: 0x%x\n",rk_mmc_property->mmc_ocr); + MMC_DBG_BOOT_FUNC("mmc,int: 0x%x\n",rk_mmc_property->mmc_int_type); + MMC_DBG_BOOT_FUNC("mmc,emmc_is_selected: 0x%x\n",rk_mmc_property->emmc_is_selected); + MMC_DBG_BOOT_FUNC("mmc,use_dma: %d %d\n",rk_mmc_property->mmc_dma_is_used[0], rk_mmc_property->mmc_dma_is_used[1]); - printk("mmc,dma_ch: %d\n",rk_mmc_property->mmc_dma_chn); - printk("=========rockchip mmc dts dump info end================\n"); -*/ + MMC_DBG_BOOT_FUNC("mmc,dma_ch: %d\n",rk_mmc_property->mmc_dma_chn); + MMC_DBG_BOOT_FUNC("=========rockchip mmc dts dump info end================\n"); } @@ -48,7 +40,7 @@ void rockchip_mmc_of_probe(struct device_node *np,struct rk_sdmmc_of *rk_mmc_pro of_property_read_u32(np, "mmc,dma_ch", &rk_mmc_property->mmc_dma_chn); }else{ - mmc_debug(MMC_DBG_WARN,"Device Tree configure mmc drivers to use pio!\n"); + MMC_DBG_WARN_FUNC("Device Tree configure mmc drivers to use pio!\n"); } rockchip_mmc_of_dump(rk_mmc_property); return ; diff --git a/drivers/mmc/host/rk_sdmmc_of.h b/drivers/mmc/host/rk_sdmmc_of.h index 923bcc23730e..b9f4f01fd3be 100755 --- a/drivers/mmc/host/rk_sdmmc_of.h +++ b/drivers/mmc/host/rk_sdmmc_of.h @@ -13,40 +13,41 @@ enum MMC_DBG_MASK{ MMC_DBG_NONE = 0, - MMC_DBG_BOOT = BIT(0), - MMC_DBG_INFO = BIT(1), - MMC_DBG_ERROR= BIT(2), - MMC_DBG_WARN = BIT(3), + MMC_DBG_BOOT = BIT(0), + MMC_DBG_ERROR= BIT(1), + MMC_DBG_WARN = BIT(2), + MMC_DBG_INFO = BIT(3), MMC_DBG_CMD = BIT(4), + MMC_DBG_DBG = BIT(5), MMC_DBG_ALL = ~0, }; +//extern u32 mmc_debug_level = MMC_DBG_ALL; -extern u32 mmc_debug_level ;//= MMC_DBG_BOOT | MMC_DBG_ERROR;/* | MMC_DBG_CMD | ...*/ - -#define mmc_error(fmt, arg...) \ - pr_err(DRIVER_PREFIX "ERROR " fmt "\n", ##arg) -#define mmc_warning(fmt, arg...) \ - pr_warning(DRIVER_PREFIX "WARNING " fmt "\n", ##arg) - -#define mmc_cmd(fmt, arg...) \ - pr_info(DRIVER_PREFIX "CMD" fmt "\n", ##arg) +#define MMC_DBG_BOOT_FUNC(fmt, arg...) \ + if(mmc_debug_level >= MMC_DBG_BOOT){ printk(DRIVER_PREFIX "BOOT " fmt "\n", ##arg);} +#define MMC_DBG_ERR_FUNC(fmt, arg...) \ + if(mmc_debug_level >= MMC_DBG_ERROR){ printk(DRIVER_PREFIX "ERROR " fmt "\n", ##arg);} +#define MMC_DBG_WARN_FUNC(fmt, arg...) \ + if(mmc_debug_level >= MMC_DBG_WARN){ printk(DRIVER_PREFIX "WARNING " fmt "\n", ##arg);} +#define MMC_DBG_INFO_FUNC(fmt, arg...) \ + if(mmc_debug_level >= MMC_DBG_INFO){ printk(DRIVER_PREFIX fmt "\n", ##arg);} +#define MMC_DBG_CMD_FUNC(fmt, arg...) \ + if(mmc_debug_level >= MMC_DBG_CMD){ printk(DRIVER_PREFIX "CMD" fmt "\n", ##arg);} -#define mmc_info(fmt, arg...) \ - pr_info(DRIVER_PREFIX fmt "\n", ##arg) + #if defined(CONFIG_DYNAMIC_DEBUG) - #define mmc_debug(level, fmt, arg...) \ + #define MMC_DBG_DEBUG_FUNC(level, fmt, arg...) \ do { \ if (unlikely(level & mmc_debug_level)) \ dynamic_pr_debug(DRIVER_PREFIX fmt "\n", ##arg); \ } while (0) #else - #define mmc_debug(level, fmt, arg...) \ + #define MMC_DBG_DEBUG_FUNC(level, fmt, arg...) \ do { \ if (unlikely(level & mmc_debug_level)) \ - printk(KERN_DEBUG pr_fmt(DRIVER_PREFIX fmt "\n"), \ - ##arg); \ + if(mmc_debug_level >= MMC_DBG_DBG){ printk(DRIVER_PREFIX fmt "\n"), ##arg);} \ } while (0) #endif -- 2.34.1