diff options
author | Wolfgang Denk <wd@denx.de> | 2011-11-04 15:55:37 +0000 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2011-11-07 22:14:10 +0100 |
commit | 937943d3f09647df9c745e5e7f55717d72426f10 (patch) | |
tree | e2beea6f1ce9fa2a670be6ac52be5c14a07db7a1 | |
parent | 09e68ffadddfaecc12caffb600a05df4e86a282c (diff) | |
download | u-boot-imx-937943d3f09647df9c745e5e7f55717d72426f10.zip u-boot-imx-937943d3f09647df9c745e5e7f55717d72426f10.tar.gz u-boot-imx-937943d3f09647df9c745e5e7f55717d72426f10.tar.bz2 |
mpc8xx/i2c.c: replace PRINTD() by debug()
This also fixes some GCC 4.6 build warnings like:
warning: variable 'txbd' set but not used [-Wunused-but-set-variable]
warning: variable 'rxbd' set but not used [-Wunused-but-set-variable]
Signed-off-by: WOlfgang Denk <wd@denx.de>
Cc: Heiko Schocher <hs@denx.de>
-rw-r--r-- | arch/powerpc/cpu/mpc8xx/i2c.c | 94 |
1 files changed, 46 insertions, 48 deletions
diff --git a/arch/powerpc/cpu/mpc8xx/i2c.c b/arch/powerpc/cpu/mpc8xx/i2c.c index 7c3727c..3e5ea3a 100644 --- a/arch/powerpc/cpu/mpc8xx/i2c.c +++ b/arch/powerpc/cpu/mpc8xx/i2c.c @@ -39,9 +39,6 @@ DECLARE_GLOBAL_DATA_PTR; -/* define to enable debug messages */ -#undef DEBUG_I2C - /* tx/rx timeout (we need the i2c early, so we don't use get_timer()) */ #define TOUT_LOOP 1000000 @@ -101,12 +98,6 @@ typedef struct i2c_state { #define I2CECB_TX_MASK 0x0f /* mask for error bits */ #define I2CECB_TIMEOUT 0x40 /* this is a timeout error */ -#ifdef DEBUG_I2C -#define PRINTD(x) printf x -#else -#define PRINTD(x) -#endif - /* * Returns the best value of I2BRG to meet desired clock speed of I2C with * input parameters (clock speed, filter, and predivider value). @@ -119,18 +110,18 @@ i2c_roundrate(int hz, int speed, int filter, int modval, { int moddiv = 1 << (5 - (modval & 3)), brgdiv, div; - PRINTD(("\t[I2C] trying hz=%d, speed=%d, filter=%d, modval=%d\n", - hz, speed, filter, modval)); + debug("\t[I2C] trying hz=%d, speed=%d, filter=%d, modval=%d\n", + hz, speed, filter, modval); div = moddiv * speed; brgdiv = (hz + div - 1) / div; - PRINTD(("\t\tmoddiv=%d, brgdiv=%d\n", moddiv, brgdiv)); + debug("\t\tmoddiv=%d, brgdiv=%d\n", moddiv, brgdiv); *brgval = ((brgdiv + 1) / 2) - 3 - (2 * filter); if ((*brgval < 0) || (*brgval > 255)) { - PRINTD(("\t\trejected brgval=%d\n", *brgval)); + debug("\t\trejected brgval=%d\n", *brgval); return -1; } @@ -138,7 +129,7 @@ i2c_roundrate(int hz, int speed, int filter, int modval, div = moddiv * brgdiv; *totspeed = hz / div; - PRINTD(("\t\taccepted brgval=%d, totspeed=%d\n", *brgval, *totspeed)); + debug("\t\taccepted brgval=%d, totspeed=%d\n", *brgval, *totspeed); return 0; } @@ -173,21 +164,22 @@ static int i2c_setrate(int hz, int speed) } } - PRINTD (("[I2C] Best is:\n")); - PRINTD (("[I2C] CPU=%dhz RATE=%d F=%d I2MOD=%08x I2BRG=%08x DIFF=%dhz\n", + debug("[I2C] Best is:\n"); + debug("[I2C] CPU=%dhz RATE=%d F=%d I2MOD=%08x I2BRG=%08x DIFF=%dhz\n", hz, speed, bestspeed_filter, bestspeed_modval, bestspeed_brgval, - bestspeed_diff)); + bestspeed_diff); i2c->i2c_i2mod |= ((bestspeed_modval & 3) << 1) | (bestspeed_filter << 3); i2c->i2c_i2brg = bestspeed_brgval & 0xff; - PRINTD (("[I2C] i2mod=%08x i2brg=%08x\n", i2c->i2c_i2mod, - i2c->i2c_i2brg)); + debug("[I2C] i2mod=%08x i2brg=%08x\n", + i2c->i2c_i2mod, + i2c->i2c_i2brg); return 1; } @@ -255,7 +247,7 @@ void i2c_init(int speed, int slaveaddr) * and current CPU rate (we assume sccr dfbgr field is 0; * divide BRGCLK by 1) */ - PRINTD(("[I2C] Setting rate...\n")); + debug("[I2C] Setting rate...\n"); i2c_setrate(gd->cpu_clk, CONFIG_SYS_I2C_SPEED); /* Set I2C controller in master mode */ @@ -270,10 +262,10 @@ void i2c_init(int speed, int slaveaddr) rxbd = (I2C_BD *) ((unsigned char *) &cp->cp_dpmem[iip->iic_rbase]); txbd = (I2C_BD *) ((unsigned char *) &cp->cp_dpmem[iip->iic_tbase]); - PRINTD(("[I2C] rbase = %04x\n", iip->iic_rbase)); - PRINTD(("[I2C] tbase = %04x\n", iip->iic_tbase)); - PRINTD(("[I2C] rxbd = %08x\n", (int)rxbd)); - PRINTD(("[I2C] txbd = %08x\n", (int)txbd)); + debug("[I2C] rbase = %04x\n", iip->iic_rbase); + debug("[I2C] tbase = %04x\n", iip->iic_tbase); + debug("[I2C] rxbd = %08x\n", (int)rxbd); + debug("[I2C] txbd = %08x\n", (int)txbd); /* Set big endian byte order */ iip->iic_tfcr = 0x10; @@ -308,7 +300,7 @@ static void i2c_newio(i2c_state_t *state) volatile cpm8xx_t *cp = (cpm8xx_t *)&immap->im_cpm; volatile iic_t *iip = (iic_t *)&cp->cp_dparam[PROFF_IIC]; - PRINTD(("[I2C] i2c_newio\n")); + debug("[I2C] i2c_newio\n"); #ifdef CONFIG_SYS_I2C_UCODE_PATCH iip = (iic_t *)&cp->cp_dpmem[iip->iic_rpbase]; @@ -321,9 +313,9 @@ static void i2c_newio(i2c_state_t *state) state->tx_buf = (uchar *)state->txbd + NUM_TX_BDS * sizeof(I2C_BD); state->err_cb = NULL; - PRINTD(("[I2C] rxbd = %08x\n", (int)state->rxbd)); - PRINTD(("[I2C] txbd = %08x\n", (int)state->txbd)); - PRINTD(("[I2C] tx_buf = %08x\n", (int)state->tx_buf)); + debug("[I2C] rxbd = %08x\n", (int)state->rxbd); + debug("[I2C] txbd = %08x\n", (int)state->txbd); + debug("[I2C] tx_buf = %08x\n", (int)state->tx_buf); /* clear the buffer memory */ memset((char *)state->tx_buf, 0, MAX_TX_SPACE); @@ -338,8 +330,8 @@ i2c_send(i2c_state_t *state, volatile I2C_BD *txbd; int i, j; - PRINTD(("[I2C] i2c_send add=%02d sec=%02d flag=%02d size=%d\n", - address, secondary_address, flags, size)); + debug("[I2C] i2c_send add=%02d sec=%02d flag=%02d size=%d\n", + address, secondary_address, flags, size); /* trying to send message larger than BD */ if (size > I2C_RXTX_LEN) @@ -352,10 +344,10 @@ i2c_send(i2c_state_t *state, txbd = (I2C_BD *) state->txbd; txbd->addr = state->tx_buf; - PRINTD(("[I2C] txbd = %08x\n", (int)txbd)); + debug("[I2C] txbd = %08x\n", (int)txbd); if (flags & I2CF_START_COND) { - PRINTD(("[I2C] Formatting addresses...\n")); + debug("[I2C] Formatting addresses...\n"); if (flags & I2CF_ENABLE_SECONDARY) { /* Length of msg + dest addr */ txbd->length = size + 2; @@ -383,15 +375,15 @@ i2c_send(i2c_state_t *state, txbd->status |= BD_SC_LAST | BD_SC_WRAP; /* Copy data to send into buffer */ - PRINTD(("[I2C] copy data...\n")); + debug("[I2C] copy data...\n"); for(j = 0; j < size; i++, j++) txbd->addr[i] = dataout[j]; - PRINTD(("[I2C] txbd: length=0x%04x status=0x%04x addr[0]=0x%02x addr[1]=0x%02x\n", + debug("[I2C] txbd: length=0x%04x status=0x%04x addr[0]=0x%02x addr[1]=0x%02x\n", txbd->length, txbd->status, txbd->addr[0], - txbd->addr[1])); + txbd->addr[1]); /* advance state */ state->tx_buf += txbd->length; @@ -411,8 +403,8 @@ i2c_receive(i2c_state_t *state, { volatile I2C_BD *rxbd, *txbd; - PRINTD(("[I2C] i2c_receive %02d %02d %02d\n", - address, secondary_address, flags)); + debug("[I2C] i2c_receive %02d %02d %02d\n", + address, secondary_address, flags); /* Expected to receive too much */ if (size_to_expect > I2C_RXTX_LEN) @@ -426,8 +418,8 @@ i2c_receive(i2c_state_t *state, rxbd = (I2C_BD *) state->rxbd; txbd = (I2C_BD *) state->txbd; - PRINTD(("[I2C] rxbd = %08x\n", (int)rxbd)); - PRINTD(("[I2C] txbd = %08x\n", (int)txbd)); + debug("[I2C] rxbd = %08x\n", (int)rxbd); + debug("[I2C] txbd = %08x\n", (int)txbd); txbd->addr = state->tx_buf; @@ -455,16 +447,16 @@ i2c_receive(i2c_state_t *state, rxbd->status |= BD_SC_WRAP; } - PRINTD(("[I2C] txbd: length=0x%04x status=0x%04x addr[0]=0x%02x addr[1]=0x%02x\n", + debug("[I2C] txbd: length=0x%04x status=0x%04x addr[0]=0x%02x addr[1]=0x%02x\n", txbd->length, txbd->status, txbd->addr[0], - txbd->addr[1])); - PRINTD(("[I2C] rxbd: length=0x%04x status=0x%04x addr[0]=0x%02x addr[1]=0x%02x\n", + txbd->addr[1]); + debug("[I2C] rxbd: length=0x%04x status=0x%04x addr[0]=0x%02x addr[1]=0x%02x\n", rxbd->length, rxbd->status, rxbd->addr[0], - rxbd->addr[1])); + rxbd->addr[1]); /* advance state */ state->tx_buf += txbd->length; @@ -487,14 +479,14 @@ static int i2c_doio(i2c_state_t *state) volatile I2C_BD *txbd, *rxbd; volatile int j = 0; - PRINTD(("[I2C] i2c_doio\n")); + debug("[I2C] i2c_doio\n"); #ifdef CONFIG_SYS_I2C_UCODE_PATCH iip = (iic_t *)&cp->cp_dpmem[iip->iic_rpbase]; #endif if (state->tx_idx <= 0 && state->rx_idx <= 0) { - PRINTD(("[I2C] No I/O is queued\n")); + debug("[I2C] No I/O is queued\n"); return I2CERR_QUEUE_EMPTY; } @@ -502,7 +494,7 @@ static int i2c_doio(i2c_state_t *state) iip->iic_tbptr = iip->iic_tbase; /* Enable I2C */ - PRINTD(("[I2C] Enabling I2C...\n")); + debug("[I2C] Enabling I2C...\n"); i2c->i2c_i2mod |= 0x01; /* Begin transmission */ @@ -512,7 +504,10 @@ static int i2c_doio(i2c_state_t *state) if (state->tx_idx > 0) { txbd = ((I2C_BD*)state->txbd) - 1; - PRINTD(("[I2C] Transmitting...(txbd=0x%08lx)\n", (ulong)txbd)); + + debug("[I2C] Transmitting...(txbd=0x%08lx)\n", + (ulong)txbd); + while ((txbd->status & BD_SC_READY) && (j++ < TOUT_LOOP)) { if (ctrlc()) return (-1); @@ -523,7 +518,10 @@ static int i2c_doio(i2c_state_t *state) if ((state->rx_idx > 0) && (j < TOUT_LOOP)) { rxbd = ((I2C_BD*)state->rxbd) - 1; - PRINTD(("[I2C] Receiving...(rxbd=0x%08lx)\n", (ulong)rxbd)); + + debug("[I2C] Receiving...(rxbd=0x%08lx)\n", + (ulong)rxbd); + while ((rxbd->status & BD_SC_EMPTY) && (j++ < TOUT_LOOP)) { if (ctrlc()) return (-1); |