SDMMC: printk independently the each information of individual controller

This commit is contained in:
xbw
2014-03-14 20:59:47 +08:00
parent 181391482c
commit 0ae1a062d7
3 changed files with 95 additions and 65 deletions

View File

@@ -343,7 +343,7 @@ static void dw_mci_start_command(struct dw_mci *host,
mci_writel(host, CMDARG, cmd->arg);
wmb();
MMC_DBG_INFO_FUNC("%d..%s start cmd=%d, arg=0x%x[%s]",__LINE__, __FUNCTION__,cmd->opcode, cmd->arg,mmc_hostname(host->mmc));
MMC_DBG_INFO_FUNC(host->mmc,"%d..%s start cmd=%d, arg=0x%x[%s]",__LINE__, __FUNCTION__,cmd->opcode, cmd->arg,mmc_hostname(host->mmc));
//dw_mci_regs_printk(host);
mci_writel(host, CMD, cmd_flags | SDMMC_CMD_START|SDMMC_CMD_USE_HOLD_REG); //always use SDMMC_CMD_USE_HOLD_REG
@@ -417,7 +417,7 @@ static void dw_mci_idmac_complete_dma(struct dw_mci *host)
struct mmc_data *data = host->data;
dev_vdbg(host->dev, "DMA complete\n");
MMC_DBG_CMD_FUNC(" DMA complete cmd=%d(arg=0x%x), blocks=%d,blksz=%d[%s]", \
MMC_DBG_CMD_FUNC(host->mmc," DMA complete cmd=%d(arg=0x%x), blocks=%d,blksz=%d[%s]", \
host->cmd->opcode,host->cmd->arg,data->blocks,data->blksz,mmc_hostname(host->mmc));
host->dma_ops->cleanup(host);
@@ -735,7 +735,7 @@ static void dw_mci_submit_data(struct dw_mci *host, struct mmc_data *data)
host->dir_status = DW_MCI_SEND_STATUS;
}
MMC_DBG_INFO_FUNC(" dw_mci_submit_data,blocks=%d,blksz=%d [%s]",\
MMC_DBG_INFO_FUNC(host->mmc," dw_mci_submit_data,blocks=%d,blksz=%d [%s]",\
data->blocks, data->blksz, mmc_hostname(host->mmc));
if (dw_mci_submit_data_dma(host, data)) {
@@ -857,7 +857,7 @@ static void dw_mci_setup_bus(struct dw_mci_slot *slot, bool force_clkinit)
host->current_speed = clock;
if(slot->ctype != slot->pre_ctype)
MMC_DBG_BOOT_FUNC("Bus speed=%dHz,Bus width=%s.[%s]", \
MMC_DBG_BOOT_FUNC(host->mmc, "Bus speed=%dHz,Bus width=%s.[%s]", \
div ? ((host->bus_hz / div) >> 1):host->bus_hz, \
(slot->ctype == SDMMC_CTYPE_4BIT)?"4bits":"8bits", mmc_hostname(host->mmc));
slot->pre_ctype = slot->ctype;
@@ -873,7 +873,7 @@ static void dw_mci_wait_unbusy(struct dw_mci *host)
unsigned int timeout= SDMMC_DATA_TIMEOUT_SDIO;
unsigned long time_loop;
unsigned int status;
MMC_DBG_INFO_FUNC(host->mmc, "dw_mci_wait_unbusy, status=0x%x ", mci_readl(host, STATUS));
if(host->mmc->restrict_caps & RESTRICT_CARD_TYPE_EMMC)
@@ -947,7 +947,7 @@ static void dw_mci_start_request(struct dw_mci *host,
{
struct mmc_request *mrq = slot->mrq;
struct mmc_command *cmd;
MMC_DBG_INFO_FUNC(host->mmc, " Begin to start the new request. cmd=%d(arg=0x%x)[%s]", \
mrq->cmd->opcode, mrq->cmd->arg, mmc_hostname(host->mmc));
@@ -989,12 +989,12 @@ static void dw_mci_request(struct mmc_host *mmc, struct mmc_request *mrq)
if (!test_bit(DW_MMC_CARD_PRESENT, &slot->flags)) {
spin_unlock_bh(&host->lock);
mrq->cmd->error = -ENOMEDIUM;
MMC_DBG_CMD_FUNC(host->mmc, "dw_mci_reqeust--reqeuest done, cmd=%d [%s]",mrq->cmd->opcode, mmc_hostname(host->mmc));
mmc_request_done(mmc, mrq);
return;
}
}
MMC_DBG_CMD_FUNC(host->mmc, "======>\n pull a new request from MMC-frame to dw_mci_queue. cmd=%d(arg=0x%x)[%s]", \
mrq->cmd->opcode, mrq->cmd->arg, mmc_hostname(host->mmc));
@@ -1279,10 +1279,10 @@ static void dw_mci_request_end(struct dw_mci *host, struct mmc_request *mrq)
dw_mci_deal_data_end(host, mrq);
if(mrq->cmd)
if(mrq->cmd)
MMC_DBG_CMD_FUNC(host->mmc, " reqeust end--reqeuest done, cmd=%d, cmderr=%d, host->state=%d [%s]",\
mrq->cmd->opcode,mrq->cmd->error, host->state,mmc_hostname(host->mmc));
if(mrq->data)
if(mrq->data)
MMC_DBG_CMD_FUNC(host->mmc, " reqeust end--reqeuest done, cmd=%d, dataerr=%d, host->state=%d [%s]",\
mrq->cmd->opcode,mrq->data->error, host->state, mmc_hostname(host->mmc));
@@ -1294,7 +1294,7 @@ static void dw_mci_request_end(struct dw_mci *host, struct mmc_request *mrq)
list_del(&slot->queue_node);
dev_vdbg(host->dev, "list not empty: %s is next\n",
mmc_hostname(slot->mmc));
host->state = STATE_SENDING_CMD;
host->state = STATE_SENDING_CMD;
MMC_DBG_CMD_FUNC(host->mmc, " list is not empty. run the request in list. [%s]", mmc_hostname(host->mmc));
dw_mci_start_request(host, slot);
} else {
@@ -1320,14 +1320,14 @@ static void dw_mci_command_complete(struct dw_mci *host, struct mmc_command *cmd
cmd->resp[2] = mci_readl(host, RESP1);
cmd->resp[1] = mci_readl(host, RESP2);
cmd->resp[0] = mci_readl(host, RESP3);
MMC_DBG_INFO_FUNC(host->mmc," command complete [%s], \ncmd=%d,resp[3]=0x%x, resp[2]=0x%x,resp[1]=0x%x,resp[0]=0x%x", \
mmc_hostname(host->mmc), cmd->opcode,cmd->resp[3], cmd->resp[2], cmd->resp[1], cmd->resp[0]);
} else {
cmd->resp[0] = mci_readl(host, RESP0);
cmd->resp[1] = 0;
cmd->resp[2] = 0;
cmd->resp[3] = 0;
cmd->resp[3] = 0;
MMC_DBG_INFO_FUNC(host->mmc, " command complete [%s], cmd=%d,resp[0]=0x%x",\
mmc_hostname(host->mmc),cmd->opcode, cmd->resp[0]);
}
@@ -1340,11 +1340,11 @@ static void dw_mci_command_complete(struct dw_mci *host, struct mmc_command *cmd
else if (status & SDMMC_INT_RESP_ERR)
cmd->error = -EIO;
else
cmd->error = 0;
cmd->error = 0;
MMC_DBG_CMD_FUNC(host->mmc, " command complete, cmd=%d,cmdError=0x%x [%s]",cmd->opcode, cmd->error,mmc_hostname(host->mmc));
if (cmd->error) {
if(MMC_SEND_STATUS != cmd->opcode)
if(MMC_SEND_STATUS != cmd->opcode)
MMC_DBG_ERR_FUNC(host->mmc, " command complete, cmd=%d,cmdError=0x%x [%s]",\
cmd->opcode, cmd->error,mmc_hostname(host->mmc));
@@ -1431,13 +1431,13 @@ static void dw_mci_tasklet_func(unsigned long priv)
#endif
state = STATE_DATA_ERROR;
break;
}
}
MMC_DBG_CMD_FUNC(host->mmc, "Pre-state[%d]-->NowState[%d]: STATE_SENDING_DATA, wait for EVENT_XFER_COMPLETE.[%s]",\
prev_state,state, mmc_hostname(host->mmc));
if (!test_and_clear_bit(EVENT_XFER_COMPLETE,
&host->pending_events))
break;
break;
MMC_DBG_INFO_FUNC(host->mmc, "Pre-state[%d]-->NowState[%d]: STATE_SENDING_DATA, wait for EVENT_DATA_COMPLETE. [%s]",\
prev_state,state,mmc_hostname(host->mmc));
@@ -1450,7 +1450,7 @@ static void dw_mci_tasklet_func(unsigned long priv)
&host->pending_events))
break;
dw_mci_deal_data_end(host, host->mrq);
dw_mci_deal_data_end(host, host->mrq);
MMC_DBG_INFO_FUNC(host->mmc, "Pre-state[%d]-->NowState[%d]: STATE_DATA_BUSY, after EVENT_DATA_COMPLETE. [%s]", \
prev_state,state,mmc_hostname(host->mmc));
@@ -1459,7 +1459,7 @@ static void dw_mci_tasklet_func(unsigned long priv)
status = host->data_status;
if (status & DW_MCI_DATA_ERROR_FLAGS) {
if((SDMMC_CTYPE_1BIT != slot->ctype)&&(MMC_SEND_EXT_CSD == host->mrq->cmd->opcode))
if((SDMMC_CTYPE_1BIT != slot->ctype)&&(MMC_SEND_EXT_CSD == host->mrq->cmd->opcode))
MMC_DBG_ERR_FUNC(host->mmc, "Pre-state[%d]-->NowState[%d]: DW_MCI_DATA_ERROR_FLAGS,datastatus=0x%x [%s]",\
prev_state,state, status, mmc_hostname(host->mmc));
@@ -1500,18 +1500,18 @@ static void dw_mci_tasklet_func(unsigned long priv)
data->error = 0;
}
if (!data->stop) {
if (!data->stop) {
MMC_DBG_CMD_FUNC(host->mmc, "Pre-state[%d]-->NowState[%d]: no stop and no dataerr, exit. [%s]", \
prev_state,state,mmc_hostname(host->mmc));
dw_mci_request_end(host, host->mrq);
goto unlock;
}
}
MMC_DBG_CMD_FUNC(host->mmc, "Pre-state[%d]-->NowState[%d]: begin to stop . [%s]", \
prev_state,state,mmc_hostname(host->mmc));
if (host->mrq->sbc && !data->error) {
data->stop->error = 0;
MMC_DBG_CMD_FUNC(host->mmc, "Pre-state[%d]-->NowState[%d]: have stop and sbc, exit. [%s]", \
prev_state,state,mmc_hostname(host->mmc));
@@ -1529,14 +1529,14 @@ static void dw_mci_tasklet_func(unsigned long priv)
send_stop_abort(host, data);
}
#endif
/* fall through */
/* fall through */
MMC_DBG_CMD_FUNC(host->mmc, "Pre-state[%d]-->NowState[%d]: begin to STATE_SENDING_STOP . [%s]", \
prev_state,state,mmc_hostname(host->mmc));
case STATE_SENDING_STOP:
if (!test_and_clear_bit(EVENT_CMD_COMPLETE,
&host->pending_events))
break;
break;
MMC_DBG_CMD_FUNC(host->mmc, "Pre-state[%d]-->NowState[%d]: begin to send cmd12 . [%s]", \
prev_state,state,mmc_hostname(host->mmc));
@@ -2036,7 +2036,7 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
}
if (pending & SDMMC_INT_DATA_OVER) {
mci_writel(host, RINTSTS, SDMMC_INT_DATA_OVER);
mci_writel(host, RINTSTS, SDMMC_INT_DATA_OVER);
MMC_DBG_CMD_FUNC(host->mmc, "SDMMC_INT_DATA_OVER, INT-pending=0x%x. [%s]",pending,mmc_hostname(host->mmc));
if (!host->data_status)
host->data_status = pending;
@@ -2061,7 +2061,7 @@ static irqreturn_t dw_mci_interrupt(int irq, void *dev_id)
dw_mci_write_data_pio(host);
}
if (pending & SDMMC_INT_CMD_DONE) {
if (pending & SDMMC_INT_CMD_DONE) {
MMC_DBG_CMD_FUNC(host->mmc, "SDMMC_INT_CMD_DONE, INT-pending=0x%x. [%s]",pending,mmc_hostname(host->mmc));
mci_writel(host, RINTSTS, SDMMC_INT_CMD_DONE);
dw_mci_cmd_interrupt(host, pending);
@@ -2111,7 +2111,7 @@ static void dw_mci_work_routine_card(struct work_struct *work)
present = dw_mci_get_cd(mmc);
while (present != slot->last_detect_state) {
dev_dbg(&slot->mmc->class_dev, "card %s\n",
present ? "inserted" : "removed");
present ? "inserted" : "removed");
MMC_DBG_BOOT_FUNC(mmc, "card %s, devname=%s \n",
present ? "inserted" : "removed", mmc_hostname(mmc));
@@ -2159,7 +2159,7 @@ static void dw_mci_work_routine_card(struct work_struct *work)
mrq->data->error = -ENOMEDIUM;
if (mrq->stop)
mrq->stop->error = -ENOMEDIUM;
MMC_DBG_CMD_FUNC(host->mmc, "dw_mci_work--reqeuest done, cmd=%d [%s]",mrq->cmd->opcode, mmc_hostname(mmc));
spin_unlock(&host->lock);
@@ -2874,6 +2874,7 @@ int dw_mci_probe(struct dw_mci *host)
"but failed on all\n", host->num_slots);
goto err_workqueue;
}
if (host->quirks & DW_MCI_QUIRK_IDMAC_DTO)
dev_info(host->dev, "Internal DMAC interrupt fix enabled.\n");

View File

@@ -8,26 +8,22 @@
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*/
#include "rk_sdmmc_of.h"
u32 mmc_debug_level= MMC_DBG_ERROR;//MMC_DBG_ALL;//set the value refer to file rk_sdmmc_of.h
u32 mmc_debug_level= MMC_DBG_INFO;//MMC_DBG_CMD//set the value refer to file rk_sdmmc_of.h
char dbg_flag[]="mmc0mmc1mmc2";
static void rockchip_mmc_of_dump(struct rk_sdmmc_of *rk_mmc_property)
{
MMC_DBG_BOOT_FUNC("=========rockchip mmc dts dump info start== 2014-03-14 15:51 ======");
/*
MMC_DBG_BOOT_FUNC("mmc,caps: 0x%x",rk_mmc_property->mmc_caps);
MMC_DBG_BOOT_FUNC("mmc,ocr: 0x%x",rk_mmc_property->mmc_ocr);
MMC_DBG_BOOT_FUNC("mmc,int: 0x%x",rk_mmc_property->mmc_int_type);
MMC_DBG_BOOT_FUNC("mmc,emmc_is_selected: 0x%x",rk_mmc_property->emmc_is_selected);
MMC_DBG_BOOT_FUNC("mmc,use_dma: %d %d",rk_mmc_property->mmc_dma_is_used[0],
printk("=========rockchip mmc dts dump info start== 2014-03-14 20:39 ======");
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_DBG_BOOT_FUNC("mmc,dma_ch: %d",rk_mmc_property->mmc_dma_chn);
MMC_DBG_BOOT_FUNC("=========rockchip mmc dts dump info end================");
*/
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");
}
@@ -38,6 +34,7 @@ void rockchip_mmc_of_probe(struct device_node *np,struct rk_sdmmc_of *rk_mmc_pro
of_property_read_u32(np, "mmc,int", &rk_mmc_property->mmc_int_type);
of_property_read_u32(np, "mmc,emmc_is_selected", &rk_mmc_property->emmc_is_selected);
of_property_read_u32_array(np, "mmc,use_dma", rk_mmc_property->mmc_dma_is_used,2);
if((&rk_mmc_property->mmc_dma_is_used[0] == MMC_USE_DMA))
{
if(rk_mmc_property->mmc_dma_is_used[1] == 0)
@@ -51,8 +48,9 @@ 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_DBG_WARN_FUNC("Device Tree configure mmc drivers to use pio!\n");
mmc_debug(MMC_DBG_WARN,"Device Tree configure mmc drivers to use pio!\n");
}
rockchip_mmc_of_dump(rk_mmc_property);
return ;

View File

@@ -33,33 +33,64 @@ enum MMC_DBG_MASK{
MMC_DBG_ALL = 0xFF,
};
extern u32 mmc_debug_level;
extern char dbg_flag[];
#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 "INFO " 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_DBG_BOOT_FUNC(mmc_host,fmt, arg...) \
do { \
if(mmc_debug_level >= MMC_DBG_NONE) { \
if(NULL != strpbrk(dbg_flag,mmc_hostname(mmc_host))) { \
printk(DRIVER_PREFIX "BOOT " fmt "\n", ##arg);\
} \
} \
}while(0)
#define MMC_DBG_ERR_FUNC(mmc_host,fmt, arg...) \
do{ \
if(mmc_debug_level >= MMC_DBG_NONE) { \
if(NULL != strpbrk(dbg_flag,mmc_hostname(mmc_host))) { \
printk(DRIVER_PREFIX "ERROR " fmt "\n", ##arg);\
} \
} \
}while(0)
#define MMC_DBG_WARN_FUNC(mmc_host,fmt, arg...) \
do { \
if(mmc_debug_level >= MMC_DBG_NONE) { \
if(NULL != strpbrk(dbg_flag,mmc_hostname(mmc_host))) { \
printk(DRIVER_PREFIX "WARN " fmt "\n", ##arg);\
} \
} \
}while(0)
#define MMC_DBG_INFO_FUNC(mmc_host,fmt, arg...) \
do { \
if(mmc_debug_level >= MMC_DBG_NONE) { \
if(NULL != strpbrk(dbg_flag,mmc_hostname(mmc_host))) { \
printk(DRIVER_PREFIX "INFO " fmt "\n", ##arg);\
} \
} \
}while(0)
#define MMC_DBG_CMD_FUNC(mmc_host,fmt, arg...) \
do { \
if(mmc_debug_level >= MMC_DBG_NONE) { \
if(NULL != strpbrk(dbg_flag,mmc_hostname(mmc_host))) { \
printk(DRIVER_PREFIX "CMD " fmt "\n", ##arg);\
} \
} \
}while(0)
#if defined(CONFIG_DYNAMIC_DEBUG)
#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)
#define mmc_debug(level, fmt, arg...) \
do { \
if (unlikely(level & mmc_debug_level)) \
dynamic_pr_debug(DRIVER_PREFIX fmt "\n", ##arg); \
} while (0)
#else
#define MMC_DBG_DEBUG_FUNC(level, fmt, arg...) \
do { \
if (unlikely(level & mmc_debug_level)) \
if(mmc_debug_level >= MMC_DBG_DBG){ printk(DRIVER_PREFIX fmt "\n"), ##arg);} \
} while (0)
#define mmc_debug(level, fmt, arg...) \
do { \
if (unlikely(level & mmc_debug_level)) \
printk(KERN_DEBUG pr_fmt(DRIVER_PREFIX fmt "\n"), \
##arg); \
} while (0)
#endif
struct rk_sdmmc_of