sam_tc.c: Fix a timer initialization bug
This commit is contained in:
parent
4647775ed2
commit
b3afc8bd75
@ -107,8 +107,8 @@
|
|||||||
# define tcdbg dbg
|
# define tcdbg dbg
|
||||||
# define tcvdbg vdbg
|
# define tcvdbg vdbg
|
||||||
#else
|
#else
|
||||||
# define wddbg(x...)
|
# define tcdbg(x...)
|
||||||
# define wdvdbg(x...)
|
# define tcvdbg(x...)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -165,9 +165,9 @@ struct sam_tc_s
|
|||||||
/* Debug stuff */
|
/* Debug stuff */
|
||||||
|
|
||||||
#ifdef CONFIG_SAMA5_TC_REGDEBUG
|
#ifdef CONFIG_SAMA5_TC_REGDEBUG
|
||||||
bool wrlast; /* Last was a write */
|
bool wr; /* True:Last was a write */
|
||||||
uint32_t addrlast; /* Last address */
|
uint32_t regaddr; /* Last address */
|
||||||
uint32_t vallast; /* Last value */
|
uint32_t regval; /* Last value */
|
||||||
int ntimes; /* Number of times */
|
int ntimes; /* Number of times */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
@ -445,9 +445,9 @@ static void sam_takesem(struct sam_tc_s *tc)
|
|||||||
static bool sam_checkreg(struct sam_tc_s *tc, bool wr, uint32_t regaddr,
|
static bool sam_checkreg(struct sam_tc_s *tc, bool wr, uint32_t regaddr,
|
||||||
uint32_t regval)
|
uint32_t regval)
|
||||||
{
|
{
|
||||||
if (wr == tc->wrlast && /* Same kind of access? */
|
if (wr == tc->wr && /* Same kind of access? */
|
||||||
regval == tc->vallast && /* Same value? */
|
regaddr == tc->regaddr && /* Same register address? */
|
||||||
regaddr == tc->addrlast) /* Same regaddr? */
|
regval == tc->regval) /* Same register value? */
|
||||||
{
|
{
|
||||||
/* Yes, then just keep a count of the number of times we did this. */
|
/* Yes, then just keep a count of the number of times we did this. */
|
||||||
|
|
||||||
@ -467,10 +467,10 @@ static bool sam_checkreg(struct sam_tc_s *tc, bool wr, uint32_t regaddr,
|
|||||||
|
|
||||||
/* Save information about the new access */
|
/* Save information about the new access */
|
||||||
|
|
||||||
tc->wrlast = wr;
|
tc->wr = wr;
|
||||||
tc->vallast = regval;
|
tc->regval = regval;
|
||||||
tc->addrlast = regaddr;
|
tc->regaddr = regaddr;
|
||||||
tc->ntimes = 0;
|
tc->ntimes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return true if this is the first time that we have done this operation */
|
/* Return true if this is the first time that we have done this operation */
|
||||||
@ -495,7 +495,7 @@ static inline uint32_t sam_tc_getreg(struct sam_chan_s *chan,
|
|||||||
uint32_t regval = getreg32(regaddr);
|
uint32_t regval = getreg32(regaddr);
|
||||||
|
|
||||||
#ifdef CONFIG_SAMA5_TC_REGDEBUG
|
#ifdef CONFIG_SAMA5_TC_REGDEBUG
|
||||||
if (sam_checkreg(tc, false, regval, regaddr))
|
if (sam_checkreg(tc, false, regaddr, regval))
|
||||||
{
|
{
|
||||||
lldbg("%08x->%08x\n", regaddr, regval);
|
lldbg("%08x->%08x\n", regaddr, regval);
|
||||||
}
|
}
|
||||||
@ -519,7 +519,7 @@ static inline void sam_tc_putreg(struct sam_chan_s *chan, uint32_t regval,
|
|||||||
uint32_t regaddr = tc->base + offset;
|
uint32_t regaddr = tc->base + offset;
|
||||||
|
|
||||||
#ifdef CONFIG_SAMA5_TC_REGDEBUG
|
#ifdef CONFIG_SAMA5_TC_REGDEBUG
|
||||||
if (sam_checkreg(tc, true, regval, regaddr))
|
if (sam_checkreg(tc, true, regaddr, regval))
|
||||||
{
|
{
|
||||||
lldbg("%08x<-%08x\n", regaddr, regval);
|
lldbg("%08x<-%08x\n", regaddr, regval);
|
||||||
}
|
}
|
||||||
@ -543,7 +543,7 @@ static inline uint32_t sam_chan_getreg(struct sam_chan_s *chan,
|
|||||||
uint32_t regval = getreg32(regaddr);
|
uint32_t regval = getreg32(regaddr);
|
||||||
|
|
||||||
#ifdef CONFIG_SAMA5_TC_REGDEBUG
|
#ifdef CONFIG_SAMA5_TC_REGDEBUG
|
||||||
if (sam_checkreg(chan->tc, false, regval, regaddr))
|
if (sam_checkreg(chan->tc, false, regaddr, regval))
|
||||||
{
|
{
|
||||||
lldbg("%08x->%08x\n", regaddr, regval);
|
lldbg("%08x->%08x\n", regaddr, regval);
|
||||||
}
|
}
|
||||||
@ -566,7 +566,7 @@ static inline void sam_chan_putreg(struct sam_chan_s *chan, unsigned int offset,
|
|||||||
uint32_t regaddr = chan->base + offset;
|
uint32_t regaddr = chan->base + offset;
|
||||||
|
|
||||||
#ifdef CONFIG_SAMA5_TC_REGDEBUG
|
#ifdef CONFIG_SAMA5_TC_REGDEBUG
|
||||||
if (sam_checkreg(chan->tc, true, regval, regaddr))
|
if (sam_checkreg(chan->tc, true, regaddr, regval))
|
||||||
{
|
{
|
||||||
lldbg("%08x<-%08x\n", regaddr, regval);
|
lldbg("%08x<-%08x\n", regaddr, regval);
|
||||||
}
|
}
|
||||||
@ -632,6 +632,7 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel)
|
|||||||
{
|
{
|
||||||
/* Timer/counter is not invalid or not enabled */
|
/* Timer/counter is not invalid or not enabled */
|
||||||
|
|
||||||
|
tcdbg("ERROR: Bad channel number: %d\n", channel);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -653,13 +654,14 @@ static inline struct sam_chan_s *sam_tc_initialize(int channel)
|
|||||||
|
|
||||||
for (i = 0, ch = tcconfig->chfirst; i < SAM_TC_NCHANNELS; i++)
|
for (i = 0, ch = tcconfig->chfirst; i < SAM_TC_NCHANNELS; i++)
|
||||||
{
|
{
|
||||||
tcdbg("Initializing TC%d\n", tcconfig->tc);
|
tcdbg("Initializing TC%d channel %d\n", tcconfig->tc, ch);
|
||||||
|
|
||||||
/* Initialize the channel data structure */
|
/* Initialize the channel data structure */
|
||||||
|
|
||||||
chan = &tc->channel[i];
|
chan = &tc->channel[i];
|
||||||
chconfig = &tcconfig->channel[i];
|
chconfig = &tcconfig->channel[i];
|
||||||
|
|
||||||
|
chan->tc = tc;
|
||||||
chan->base = chconfig->base;
|
chan->base = chconfig->base;
|
||||||
chan->chan = ch++;
|
chan->chan = ch++;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user