Centralize definitions associated with CONFIG_DEBUG_SDIO/MEMCARD

This commit is contained in:
Gregory Nutt 2016-06-16 07:50:54 -06:00
parent b7f0fbc073
commit 7a9f1814a2
3 changed files with 136 additions and 53 deletions

35
Kconfig
View File

@ -1225,15 +1225,44 @@ config DEBUG_RTC_INFO
endif # DEBUG_RTC
config DEBUG_SDIO
bool "SDIO Debug Output"
config DEBUG_MEMCARD
bool "Memory Card Driver Debug Features"
default n
depends on MMCSD_SDIO
---help---
Enable SDIO driver debug SYSLOG output (disabled by default).
Enable MMC/SD memory card Driver debug features.
Support for this debug option is architecture-specific and may not
be available for some MCUs.
if DEBUG_MEMCARD
config DEBUG_MEMCARD_ERROR
bool "Memory Card Driver Error Output"
default n
depends on DEBUG_ERROR
---help---
Enable MMC/SD memory card driver error output to SYSLOG.
Support for this debug option is architecture-specific and may not
be available for some MCUs.
config DEBUG_MEMCARD_WARN
bool "Memory Card Driver Warnings Output"
default n
depends on DEBUG_WARN
---help---
Enable MMC/SD memory card driver warning output to SYSLOG.
config DEBUG_MEMCARD_INFO
bool "Memory Card Driver Informational Output"
default n
depends on DEBUG_INFO
---help---
Enable MMC/SD memory card driver informational output to SYSLOG.
endif # DEBUG_MEMCARD
config DEBUG_SENSORS
bool "Sensor Debug Features"
default n

View File

@ -93,7 +93,7 @@
* CONFIG_SDIO_WIDTH_D1_ONLY - This may be selected to force the driver
* operate with only a single data line (the default is to use all
* 4 SD data lines).
* CONFIG_DEBUG_SDIO - Enables some very low-level debug output
* CONFIG_DEBUG_MEMCARD_* - Enables some very low-level debug output
* This also requires CONFIG_DEBUG_FS and CONFIG_DEBUG_INFO
*/
@ -109,10 +109,6 @@
# error "Callback support requires CONFIG_SCHED_WORKQUEUE"
#endif
#if !defined(CONFIG_DEBUG_FS) || !defined(CONFIG_DEBUG_FEATURES)
# undef CONFIG_DEBUG_SDIO
#endif
/* Friendly CLKCR bit re-definitions ****************************************/
/* Mode dependent settings. These depend on clock devisor settings that must
@ -213,7 +209,7 @@
/* Register logging support */
#ifdef CONFIG_DEBUG_SDIO
#ifdef CONFIG_DEBUG_MEMCARD_INFO
# ifdef CONFIG_SDIO_DMA
# define SAMPLENDX_BEFORE_SETUP 0
# define SAMPLENDX_BEFORE_ENABLE 1
@ -274,7 +270,7 @@ struct lpc17_dev_s
/* Register logging support */
#ifdef CONFIG_DEBUG_SDIO
#ifdef CONFIG_DEBUG_MEMCARD_INFO
struct lpc17_sdcard_regs_s
{
uint8_t pwr;
@ -314,7 +310,7 @@ static inline uint32_t lpc17_getpwrctrl(void);
/* DMA Helpers **************************************************************/
#ifdef CONFIG_DEBUG_SDIO
#ifdef CONFIG_DEBUG_MEMCARD_INFO
static void lpc17_sampleinit(void);
static void lpc17_sdcard_sample(struct lpc17_sdcard_regs_s *regs);
static void lpc17_sample(struct lpc17_dev_s *priv, int index);
@ -452,7 +448,7 @@ struct lpc17_dev_s g_scard_dev =
/* Register logging support */
#ifdef CONFIG_DEBUG_SDIO
#ifdef CONFIG_DEBUG_MEMCARD_INFO
static struct lpc17_sampleregs_s g_sampleregs[DEBUG_NSAMPLES];
#endif
@ -529,8 +525,8 @@ static inline void lpc17_setclock(uint32_t clkcr)
regval |= clkcr;
putreg32(regval, LPC17_SDCARD_CLOCK);
finfo("CLKCR: %08x PWR: %08x\n",
getreg32(LPC17_SDCARD_CLOCK), getreg32(LPC17_SDCARD_PWR));
mcinfo("CLKCR: %08x PWR: %08x\n",
getreg32(LPC17_SDCARD_CLOCK), getreg32(LPC17_SDCARD_PWR));
}
/****************************************************************************
@ -659,7 +655,7 @@ static inline uint32_t lpc17_getpwrctrl(void)
*
****************************************************************************/
#ifdef CONFIG_DEBUG_SDIO
#ifdef CONFIG_DEBUG_MEMCARD_INFO
static void lpc17_sampleinit(void)
{
memset(g_sampleregs, 0xff, DEBUG_NSAMPLES * sizeof(struct lpc17_sampleregs_s));
@ -674,7 +670,7 @@ static void lpc17_sampleinit(void)
*
****************************************************************************/
#ifdef CONFIG_DEBUG_SDIO
#ifdef CONFIG_DEBUG_MEMCARD_INFO
static void lpc17_sdcard_sample(struct lpc17_sdcard_regs_s *regs)
{
regs->pwr = (uint8_t)getreg32(LPC17_SDCARD_PWR);
@ -697,7 +693,7 @@ static void lpc17_sdcard_sample(struct lpc17_sdcard_regs_s *regs)
*
****************************************************************************/
#ifdef CONFIG_DEBUG_SDIO
#ifdef CONFIG_DEBUG_MEMCARD_INFO
static void lpc17_sample(struct lpc17_dev_s *priv, int index)
{
struct lpc17_sampleregs_s *regs = &g_sampleregs[index];
@ -707,6 +703,7 @@ static void lpc17_sample(struct lpc17_dev_s *priv, int index)
lpc17_dmasample(priv->dma, &regs->dma);
}
#endif
lpc17_sdcard_sample(&regs->sdcard);
}
#endif
@ -719,19 +716,19 @@ static void lpc17_sample(struct lpc17_dev_s *priv, int index)
*
****************************************************************************/
#ifdef CONFIG_DEBUG_SDIO
#ifdef CONFIG_DEBUG_MEMCARD_INFO
static void lpc17_sdcard_dump(struct lpc17_sdcard_regs_s *regs, const char *msg)
{
ferr("SD Card Registers: %s\n", msg);
ferr(" POWER[%08x]: %08x\n", LPC17_SDCARD_PWR, regs->pwr);
ferr(" CLKCR[%08x]: %08x\n", LPC17_SDCARD_CLOCK, regs->clkcr);
ferr(" DCTRL[%08x]: %08x\n", LPC17_SDCARD_DCTRL, regs->dctrl);
ferr(" DTIMER[%08x]: %08x\n", LPC17_SDCARD_DTIMER, regs->dtimer);
ferr(" DLEN[%08x]: %08x\n", LPC17_SDCARD_DLEN, regs->dlen);
ferr(" DCOUNT[%08x]: %08x\n", LPC17_SDCARD_DCOUNT, regs->dcount);
ferr(" STA[%08x]: %08x\n", LPC17_SDCARD_STATUS, regs->sta);
ferr(" MASK[%08x]: %08x\n", LPC17_SDCARD_MASK0, regs->mask);
ferr("FIFOCNT[%08x]: %08x\n", LPC17_SDCARD_FIFOCNT, regs->fifocnt);
mcinfo("SD Card Registers: %s\n", msg);
mcinfo(" POWER[%08x]: %08x\n", LPC17_SDCARD_PWR, regs->pwr);
mcinfo(" CLKCR[%08x]: %08x\n", LPC17_SDCARD_CLOCK, regs->clkcr);
mcinfo(" DCTRL[%08x]: %08x\n", LPC17_SDCARD_DCTRL, regs->dctrl);
mcinfo(" DTIMER[%08x]: %08x\n", LPC17_SDCARD_DTIMER, regs->dtimer);
mcinfo(" DLEN[%08x]: %08x\n", LPC17_SDCARD_DLEN, regs->dlen);
mcinfo(" DCOUNT[%08x]: %08x\n", LPC17_SDCARD_DCOUNT, regs->dcount);
mcinfo(" STA[%08x]: %08x\n", LPC17_SDCARD_STATUS, regs->sta);
mcinfo(" MASK[%08x]: %08x\n", LPC17_SDCARD_MASK0, regs->mask);
mcinfo("FIFOCNT[%08x]: %08x\n", LPC17_SDCARD_FIFOCNT, regs->fifocnt);
}
#endif
@ -743,7 +740,7 @@ static void lpc17_sdcard_dump(struct lpc17_sdcard_regs_s *regs, const char *msg)
*
****************************************************************************/
#ifdef CONFIG_DEBUG_SDIO
#ifdef CONFIG_DEBUG_MEMCARD_INFO
static void lpc17_dumpsample(struct lpc17_dev_s *priv,
struct lpc17_sampleregs_s *regs, const char *msg)
{
@ -765,7 +762,7 @@ static void lpc17_dumpsample(struct lpc17_dev_s *priv,
*
****************************************************************************/
#ifdef CONFIG_DEBUG_SDIO
#ifdef CONFIG_DEBUG_MEMCARD_INFO
static void lpc17_dumpsamples(struct lpc17_dev_s *priv)
{
lpc17_dumpsample(priv, &g_sampleregs[SAMPLENDX_BEFORE_SETUP], "Before setup");
@ -1480,8 +1477,8 @@ static void lpc17_reset(FAR struct sdio_dev_s *dev)
lpc17_setpwrctrl(SDCARD_PWR_CTRL_ON);
leave_critical_section(flags);
finfo("CLCKR: %08x POWER: %08x\n",
getreg32(LPC17_SDCARD_CLOCK), getreg32(LPC17_SDCARD_PWR));
mcinfo("CLCKR: %08x POWER: %08x\n",
getreg32(LPC17_SDCARD_CLOCK), getreg32(LPC17_SDCARD_PWR));
}
/****************************************************************************
@ -1689,7 +1686,7 @@ static int lpc17_sendcmd(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t arg)
cmdidx = (cmd & MMCSD_CMDIDX_MASK) >> MMCSD_CMDIDX_SHIFT;
regval |= cmdidx | SDCARD_CMD_CPSMEN;
finfo("cmd: %08x arg: %08x regval: %08x\n", cmd, arg, regval);
mcinfo("cmd: %08x arg: %08x regval: %08x\n", cmd, arg, regval);
/* Write the SD card CMD */
@ -1920,7 +1917,7 @@ static int lpc17_waitresponse(FAR struct sdio_dev_s *dev, uint32_t cmd)
{
if (--timeout <= 0)
{
ferr("ERROR: Timeout cmd: %08x events: %08x STA: %08x\n",
mcerr("ERROR: Timeout cmd: %08x events: %08x STA: %08x\n",
cmd, events, getreg32(LPC17_SDCARD_STATUS));
return -ETIMEDOUT;
@ -1987,7 +1984,7 @@ static int lpc17_recvshortcrc(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t
#ifdef CONFIG_DEBUG_FEATURES
if (!rshort)
{
ferr("ERROR: rshort=NULL\n");
mcerr("ERROR: rshort=NULL\n");
ret = -EINVAL;
}
@ -1997,7 +1994,7 @@ static int lpc17_recvshortcrc(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t
(cmd & MMCSD_RESPONSE_MASK) != MMCSD_R1B_RESPONSE &&
(cmd & MMCSD_RESPONSE_MASK) != MMCSD_R6_RESPONSE)
{
ferr("ERROR: Wrong response CMD=%08x\n", cmd);
mcerr("ERROR: Wrong response CMD=%08x\n", cmd);
ret = -EINVAL;
}
else
@ -2008,12 +2005,12 @@ static int lpc17_recvshortcrc(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t
regval = getreg32(LPC17_SDCARD_STATUS);
if ((regval & SDCARD_STATUS_CTIMEOUT) != 0)
{
ferr("ERROR: Command timeout: %08x\n", regval);
mcerr("ERROR: Command timeout: %08x\n", regval);
ret = -ETIMEDOUT;
}
else if ((regval & SDCARD_STATUS_CCRCFAIL) != 0)
{
ferr("ERROR: CRC failure: %08x\n", regval);
mcerr("ERROR: CRC failure: %08x\n", regval);
ret = -EIO;
}
#ifdef CONFIG_DEBUG_FEATURES
@ -2024,7 +2021,7 @@ static int lpc17_recvshortcrc(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t
respcmd = getreg32(LPC17_SDCARD_RESPCMD);
if ((uint8_t)(respcmd & SDCARD_RESPCMD_MASK) != (cmd & MMCSD_CMDIDX_MASK))
{
ferr("ERROR: RESCMD=%02x CMD=%08x\n", respcmd, cmd);
mcerr("ERROR: RESCMD=%02x CMD=%08x\n", respcmd, cmd);
ret = -EINVAL;
}
}
@ -2057,7 +2054,7 @@ static int lpc17_recvlong(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t rlo
if ((cmd & MMCSD_RESPONSE_MASK) != MMCSD_R2_RESPONSE)
{
ferr("ERROR: Wrong response CMD=%08x\n", cmd);
mcerr("ERROR: Wrong response CMD=%08x\n", cmd);
ret = -EINVAL;
}
else
@ -2068,12 +2065,12 @@ static int lpc17_recvlong(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t rlo
regval = getreg32(LPC17_SDCARD_STATUS);
if (regval & SDCARD_STATUS_CTIMEOUT)
{
ferr("ERROR: Timeout STA: %08x\n", regval);
mcerr("ERROR: Timeout STA: %08x\n", regval);
ret = -ETIMEDOUT;
}
else if (regval & SDCARD_STATUS_CCRCFAIL)
{
ferr("ERROR: CRC fail STA: %08x\n", regval);
mcerr("ERROR: CRC fail STA: %08x\n", regval);
ret = -EIO;
}
}
@ -2111,7 +2108,7 @@ static int lpc17_recvshort(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t *r
if ((cmd & MMCSD_RESPONSE_MASK) != MMCSD_R3_RESPONSE &&
(cmd & MMCSD_RESPONSE_MASK) != MMCSD_R7_RESPONSE)
{
ferr("ERROR: Wrong response CMD=%08x\n", cmd);
mcerr("ERROR: Wrong response CMD=%08x\n", cmd);
ret = -EINVAL;
}
else
@ -2124,7 +2121,7 @@ static int lpc17_recvshort(FAR struct sdio_dev_s *dev, uint32_t cmd, uint32_t *r
regval = getreg32(LPC17_SDCARD_STATUS);
if (regval & SDCARD_STATUS_CTIMEOUT)
{
ferr("ERROR: Timeout STA: %08x\n", regval);
mcerr("ERROR: Timeout STA: %08x\n", regval);
ret = -ETIMEDOUT;
}
}
@ -2269,7 +2266,7 @@ static sdio_eventset_t lpc17_eventwait(FAR struct sdio_dev_s *dev,
1, (uint32_t)priv);
if (ret != OK)
{
ferr("ERROR: wd_start failed: %d\n", ret);
mcerr("ERROR: wd_start failed: %d\n", ret);
}
}
@ -2341,7 +2338,7 @@ static void lpc17_callbackenable(FAR struct sdio_dev_s *dev,
{
struct lpc17_dev_s *priv = (struct lpc17_dev_s *)dev;
finfo("eventset: %02x\n", eventset);
mcinfo("eventset: %02x\n", eventset);
DEBUGASSERT(priv != NULL);
priv->cbevents = eventset;
@ -2377,7 +2374,7 @@ static int lpc17_registercallback(FAR struct sdio_dev_s *dev,
/* Disable callbacks and register this callback and is argument */
finfo("Register %p(%p)\n", callback, arg);
mcinfo("Register %p(%p)\n", callback, arg);
DEBUGASSERT(priv != NULL);
priv->cbevents = 0;
@ -2590,8 +2587,8 @@ static void lpc17_callback(void *arg)
/* Is a callback registered? */
DEBUGASSERT(priv != NULL);
finfo("Callback %p(%p) cbevents: %02x cdstatus: %02x\n",
priv->callback, priv->cbarg, priv->cbevents, priv->cdstatus);
mcinfo("Callback %p(%p) cbevents: %02x cdstatus: %02x\n",
priv->callback, priv->cbarg, priv->cbevents, priv->cdstatus);
if (priv->callback)
{
@ -2635,14 +2632,14 @@ static void lpc17_callback(void *arg)
{
/* Yes.. queue it */
finfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg);
mcinfo("Queuing callback to %p(%p)\n", priv->callback, priv->cbarg);
(void)work_queue(HPWORK, &priv->cbwork, (worker_t)priv->callback, priv->cbarg, 0);
}
else
{
/* No.. then just call the callback here */
finfo("Callback to %p(%p)\n", priv->callback, priv->cbarg);
mcinfo("Callback to %p(%p)\n", priv->callback, priv->cbarg);
priv->callback(priv->cbarg);
}
}
@ -2781,7 +2778,7 @@ void sdio_mediachange(FAR struct sdio_dev_s *dev, bool cardinslot)
{
priv->cdstatus &= ~SDIO_STATUS_PRESENT;
}
finfo("cdstatus OLD: %02x NEW: %02x\n", cdstatus, priv->cdstatus);
mcinfo("cdstatus OLD: %02x NEW: %02x\n", cdstatus, priv->cdstatus);
/* Perform any requested callback if the status has changed */
@ -2824,7 +2821,8 @@ void sdio_wrprotect(FAR struct sdio_dev_s *dev, bool wrprotect)
{
priv->cdstatus &= ~SDIO_STATUS_WRPROTECTED;
}
finfo("cdstatus: %02x\n", priv->cdstatus);
mcinfo("cdstatus: %02x\n", priv->cdstatus);
leave_critical_section(flags);
}
#endif /* CONFIG_LPC17_SDCARD */

View File

@ -717,6 +717,30 @@
# define rtcllinfo(x...)
#endif
#ifdef CONFIG_DEBUG_MEMCARD_ERROR
# define mcerr(format, ...) err(format, ##__VA_ARGS__)
# define mcllerr(format, ...) llerr(format, ##__VA_ARGS__)
#else
# define mcerr(x...)
# define mcllerr(x...)
#endif
#ifdef CONFIG_DEBUG_MEMCARD_WARN
# define mcwarn(format, ...) warn(format, ##__VA_ARGS__)
# define mcllwarn(format, ...) llwarn(format, ##__VA_ARGS__)
#else
# define mcwarn(x...)
# define mcllwarn(x...)
#endif
#ifdef CONFIG_DEBUG_MEMCARD_INFO
# define mcinfo(format, ...) info(format, ##__VA_ARGS__)
# define mcllinfo(format, ...) llinfo(format, ##__VA_ARGS__)
#else
# define mcinfo(x...)
# define mcllinfo(x...)
#endif
#ifdef CONFIG_DEBUG_SENSORS_ERROR
# define snerr(format, ...) err(format, ##__VA_ARGS__)
# define snllerr(format, ...) llerr(format, ##__VA_ARGS__)
@ -1402,6 +1426,30 @@
# define rtcllinfo (void)
#endif
#ifdef CONFIG_DEBUG_MEMCARD_ERROR
# define mcerr err
# define mcllerr llerr
#else
# define mcerr (void)
# define mcllerr (void)
#endif
#ifdef CONFIG_DEBUG_MEMCARD_WARN
# define mcwarn warn
# define mcllwarn llwarn
#else
# define mcwarn (void)
# define mcllwarn (void)
#endif
#ifdef CONFIG_DEBUG_MEMCARD_INFO
# define mcinfo info
# define mcllinfo llinfo
#else
# define mcinfo (void)
# define mcllinfo (void)
#endif
#ifdef CONFIG_DEBUG_SENSORS_ERROR
# define snerr err
# define snllerr llerr
@ -1708,6 +1756,14 @@
# define rtcinfodumpbuffer(m,b,n)
#endif
#ifdef CONFIG_DEBUG_MEMCARD
# define mcerrdumpbuffer(m,b,n) errdumpbuffer(m,b,n)
# define mcinfodumpbuffer(m,b,n) infodumpbuffer(m,b,n)
#else
# define mcerrdumpbuffer(m,b,n)
# define mcinfodumpbuffer(m,b,n)
#endif
#ifdef CONFIG_DEBUG_SENSORS
# define snerrdumpbuffer(m,b,n) errdumpbuffer(m,b,n)
# define sninfodumpbuffer(m,b,n) infodumpbuffer(m,b,n)