aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/savage
diff options
context:
space:
mode:
authorAntonino A. Daplas <adaplas@gmail.com>2007-05-08 03:38:34 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-08 14:15:29 -0400
commitf7829158bce2c8180bf7a1cb922cad812d3a2788 (patch)
tree318070b6d6cd2d852c8142c1ec959f8dcb74c8db /drivers/video/savage
parent7dfe50b3aac2b3500139ab10a6e228d34fed9a49 (diff)
savagefb: rework i2c bit access
Use already defined VGAwCR/VGArCR functions to access the i2c bus. Signed-off-by: Antonino Daplas <adaplas@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/video/savage')
-rw-r--r--drivers/video/savage/savagefb-i2c.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/video/savage/savagefb-i2c.c b/drivers/video/savage/savagefb-i2c.c
index 8db066ccca6b..35c1ce62b216 100644
--- a/drivers/video/savage/savagefb-i2c.c
+++ b/drivers/video/savage/savagefb-i2c.c
@@ -41,10 +41,6 @@
41#define SAVAGE4_I2C_SCL_IN 0x00000008 41#define SAVAGE4_I2C_SCL_IN 0x00000008
42#define SAVAGE4_I2C_SDA_IN 0x00000010 42#define SAVAGE4_I2C_SDA_IN 0x00000010
43 43
44#define SET_CR_IX(base, val) writeb((val), base + 0x8000 + VGA_CR_IX)
45#define SET_CR_DATA(base, val) writeb((val), base + 0x8000 + VGA_CR_DATA)
46#define GET_CR_DATA(base) readb(base + 0x8000 + VGA_CR_DATA)
47
48static void savage4_gpio_setscl(void *data, int val) 44static void savage4_gpio_setscl(void *data, int val)
49{ 45{
50 struct savagefb_i2c_chan *chan = data; 46 struct savagefb_i2c_chan *chan = data;
@@ -92,15 +88,15 @@ static void prosavage_gpio_setscl(void* data, int val)
92 struct savagefb_i2c_chan *chan = data; 88 struct savagefb_i2c_chan *chan = data;
93 u32 r; 89 u32 r;
94 90
95 SET_CR_IX(chan->ioaddr, chan->reg); 91 r = VGArCR(chan->reg, chan->par);
96 r = GET_CR_DATA(chan->ioaddr);
97 r |= PROSAVAGE_I2C_ENAB; 92 r |= PROSAVAGE_I2C_ENAB;
98 if (val) { 93 if (val) {
99 r |= PROSAVAGE_I2C_SCL_OUT; 94 r |= PROSAVAGE_I2C_SCL_OUT;
100 } else { 95 } else {
101 r &= ~PROSAVAGE_I2C_SCL_OUT; 96 r &= ~PROSAVAGE_I2C_SCL_OUT;
102 } 97 }
103 SET_CR_DATA(chan->ioaddr, r); 98
99 VGAwCR(chan->reg, r, chan->par);
104} 100}
105 101
106static void prosavage_gpio_setsda(void* data, int val) 102static void prosavage_gpio_setsda(void* data, int val)
@@ -108,31 +104,29 @@ static void prosavage_gpio_setsda(void* data, int val)
108 struct savagefb_i2c_chan *chan = data; 104 struct savagefb_i2c_chan *chan = data;
109 unsigned int r; 105 unsigned int r;
110 106
111 SET_CR_IX(chan->ioaddr, chan->reg); 107 r = VGArCR(chan->reg, chan->par);
112 r = GET_CR_DATA(chan->ioaddr);
113 r |= PROSAVAGE_I2C_ENAB; 108 r |= PROSAVAGE_I2C_ENAB;
114 if (val) { 109 if (val) {
115 r |= PROSAVAGE_I2C_SDA_OUT; 110 r |= PROSAVAGE_I2C_SDA_OUT;
116 } else { 111 } else {
117 r &= ~PROSAVAGE_I2C_SDA_OUT; 112 r &= ~PROSAVAGE_I2C_SDA_OUT;
118 } 113 }
119 SET_CR_DATA(chan->ioaddr, r); 114
115 VGAwCR(chan->reg, r, chan->par);
120} 116}
121 117
122static int prosavage_gpio_getscl(void* data) 118static int prosavage_gpio_getscl(void* data)
123{ 119{
124 struct savagefb_i2c_chan *chan = data; 120 struct savagefb_i2c_chan *chan = data;
125 121
126 SET_CR_IX(chan->ioaddr, chan->reg); 122 return (VGArCR(chan->reg, chan->par) & PROSAVAGE_I2C_SCL_IN) ? 1 : 0;
127 return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SCL_IN));
128} 123}
129 124
130static int prosavage_gpio_getsda(void* data) 125static int prosavage_gpio_getsda(void* data)
131{ 126{
132 struct savagefb_i2c_chan *chan = data; 127 struct savagefb_i2c_chan *chan = data;
133 128
134 SET_CR_IX(chan->ioaddr, chan->reg); 129 return (VGArCR(chan->reg, chan->par) & PROSAVAGE_I2C_SDA_IN) ? 1 : 0;
135 return (0 != (GET_CR_DATA(chan->ioaddr) & PROSAVAGE_I2C_SDA_IN));
136} 130}
137 131
138static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan, 132static int savage_setup_i2c_bus(struct savagefb_i2c_chan *chan,