Commit f7829158 authored by Antonino A. Daplas's avatar Antonino A. Daplas Committed by Linus Torvalds

savagefb: rework i2c bit access

Use already defined VGAwCR/VGArCR functions to access the i2c bus.
Signed-off-by: default avatarAntonino Daplas <adaplas@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7dfe50b3
...@@ -41,10 +41,6 @@ ...@@ -41,10 +41,6 @@
#define SAVAGE4_I2C_SCL_IN 0x00000008 #define SAVAGE4_I2C_SCL_IN 0x00000008
#define SAVAGE4_I2C_SDA_IN 0x00000010 #define SAVAGE4_I2C_SDA_IN 0x00000010
#define SET_CR_IX(base, val) writeb((val), base + 0x8000 + VGA_CR_IX)
#define SET_CR_DATA(base, val) writeb((val), base + 0x8000 + VGA_CR_DATA)
#define GET_CR_DATA(base) readb(base + 0x8000 + VGA_CR_DATA)
static void savage4_gpio_setscl(void *data, int val) static void savage4_gpio_setscl(void *data, int val)
{ {
struct savagefb_i2c_chan *chan = data; struct savagefb_i2c_chan *chan = data;
...@@ -92,15 +88,15 @@ static void prosavage_gpio_setscl(void* data, int val) ...@@ -92,15 +88,15 @@ static void prosavage_gpio_setscl(void* data, int val)
struct savagefb_i2c_chan *chan = data; struct savagefb_i2c_chan *chan = data;
u32 r; u32 r;
SET_CR_IX(chan->ioaddr, chan->reg); r = VGArCR(chan->reg, chan->par);
r = GET_CR_DATA(chan->ioaddr);
r |= PROSAVAGE_I2C_ENAB; r |= PROSAVAGE_I2C_ENAB;
if (val) { if (val) {
r |= PROSAVAGE_I2C_SCL_OUT; r |= PROSAVAGE_I2C_SCL_OUT;
} else { } else {
r &= ~PROSAVAGE_I2C_SCL_OUT; r &= ~PROSAVAGE_I2C_SCL_OUT;
} }
SET_CR_DATA(chan->ioaddr, r);
VGAwCR(chan->reg, r, chan->par);
} }
static void prosavage_gpio_setsda(void* data, int val) static void prosavage_gpio_setsda(void* data, int val)
...@@ -108,31 +104,29 @@ static void prosavage_gpio_setsda(void* data, int val) ...@@ -108,31 +104,29 @@ static void prosavage_gpio_setsda(void* data, int val)
struct savagefb_i2c_chan *chan = data; struct savagefb_i2c_chan *chan = data;
unsigned int r; unsigned int r;
SET_CR_IX(chan->ioaddr, chan->reg); r = VGArCR(chan->reg, chan->par);
r = GET_CR_DATA(chan->ioaddr);
r |= PROSAVAGE_I2C_ENAB; r |= PROSAVAGE_I2C_ENAB;
if (val) { if (val) {
r |= PROSAVAGE_I2C_SDA_OUT; r |= PROSAVAGE_I2C_SDA_OUT;
} else { } else {
r &= ~PROSAVAGE_I2C_SDA_OUT; r &= ~PROSAVAGE_I2C_SDA_OUT;
} }
SET_CR_DATA(chan->ioaddr, r);
VGAwCR(chan->reg, r, chan->par);
} }
static int prosavage_gpio_getscl(void* data) static int prosavage_gpio_getscl(void* data)
{ {
struct savagefb_i2c_chan *chan = data; struct savagefb_i2c_chan *chan = data;
SET_CR_IX(chan->ioaddr, chan->reg); return (VGArCR(chan->reg, chan->par) & PROSAVAGE_I2C_SCL_IN) ? 1 : 0;
return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SCL_IN));
} }
static int prosavage_gpio_getsda(void* data) static int prosavage_gpio_getsda(void* data)
{ {
struct savagefb_i2c_chan *chan = data; struct savagefb_i2c_chan *chan = data;
SET_CR_IX(chan->ioaddr, chan->reg); return (VGArCR(chan->reg, chan->par) & PROSAVAGE_I2C_SDA_IN) ? 1 : 0;
return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SDA_IN));
} }
static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan, static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment