diff options
author | Mike Rapoport <mike.rapoport@gmail.com> | 2016-02-10 18:34:20 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-02-11 19:52:37 -0800 |
commit | b71413e0d557684293a10fb1cd5747956ef42bd4 (patch) | |
tree | 21d4c777218e10b2c469c52039e1c87a4a67ca31 /drivers/staging/sm750fb/ddk750_hwi2c.c | |
parent | cdce1f187733feb25a0fa5d4a3043bf635f2f8ce (diff) | |
download | linux-stable-b71413e0d557684293a10fb1cd5747956ef42bd4.tar.gz linux-stable-b71413e0d557684293a10fb1cd5747956ef42bd4.tar.bz2 linux-stable-b71413e0d557684293a10fb1cd5747956ef42bd4.zip |
staging: sm750fb: use BIT macro for I2C_CTRL fields
Replace complex definition of I2C_CTRL register fields with BIT() macro and
use open-coded implementation for register manipulation
Signed-off-by: Mike Rapoport <mike.rapoport@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/sm750fb/ddk750_hwi2c.c')
-rw-r--r-- | drivers/staging/sm750fb/ddk750_hwi2c.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/drivers/staging/sm750fb/ddk750_hwi2c.c b/drivers/staging/sm750fb/ddk750_hwi2c.c index 40253bd8cf2a..1811c4bd007f 100644 --- a/drivers/staging/sm750fb/ddk750_hwi2c.c +++ b/drivers/staging/sm750fb/ddk750_hwi2c.c @@ -26,12 +26,10 @@ unsigned char bus_speed_mode enableI2C(1); /* Enable the I2C Controller and set the bus speed mode */ - value = PEEK32(I2C_CTRL); - if (bus_speed_mode == 0) - value = FIELD_SET(value, I2C_CTRL, MODE, STANDARD); - else - value = FIELD_SET(value, I2C_CTRL, MODE, FAST); - value = FIELD_SET(value, I2C_CTRL, EN, ENABLE); + value = PEEK32(I2C_CTRL) & ~(I2C_CTRL_MODE | I2C_CTRL_EN); + if (bus_speed_mode) + value |= I2C_CTRL_MODE; + value |= I2C_CTRL_EN; POKE32(I2C_CTRL, value); return 0; @@ -42,8 +40,7 @@ void sm750_hw_i2c_close(void) unsigned int value; /* Disable I2C controller */ - value = PEEK32(I2C_CTRL); - value = FIELD_SET(value, I2C_CTRL, EN, DISABLE); + value = PEEK32(I2C_CTRL) & ~I2C_CTRL_EN; POKE32(I2C_CTRL, value); /* Disable I2C Power */ @@ -120,8 +117,7 @@ static unsigned int hw_i2c_write_data( POKE32(I2C_DATA0 + i, *buf++); /* Start the I2C */ - POKE32(I2C_CTRL, - FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START)); + POKE32(I2C_CTRL, PEEK32(I2C_CTRL) | I2C_CTRL_CTRL); /* Wait until the transfer is completed. */ if (hw_i2c_wait_tx_done() != 0) @@ -183,8 +179,7 @@ static unsigned int hw_i2c_read_data( POKE32(I2C_BYTE_COUNT, count); /* Start the I2C */ - POKE32(I2C_CTRL, - FIELD_SET(PEEK32(I2C_CTRL), I2C_CTRL, CTRL, START)); + POKE32(I2C_CTRL, PEEK32(I2C_CTRL) | I2C_CTRL_CTRL); /* Wait until transaction done. */ if (hw_i2c_wait_tx_done() != 0) |