13 #include <linux/module.h>
14 #include <linux/kernel.h>
17 #include <linux/pci.h>
23 #define SAVAGE_DDC 0x50
25 #define VGA_CR_IX 0x3d4
26 #define VGA_CR_DATA 0x3d5
28 #define CR_SERIAL1 0xa0
29 #define MM_SERIAL1 0xff20
30 #define CR_SERIAL2 0xb1
33 #define PROSAVAGE_I2C_ENAB 0x10
34 #define PROSAVAGE_I2C_SCL_OUT 0x01
35 #define PROSAVAGE_I2C_SDA_OUT 0x02
36 #define PROSAVAGE_I2C_SCL_IN 0x04
37 #define PROSAVAGE_I2C_SDA_IN 0x08
39 #define SAVAGE4_I2C_ENAB 0x00000020
40 #define SAVAGE4_I2C_SCL_OUT 0x00000001
41 #define SAVAGE4_I2C_SDA_OUT 0x00000002
42 #define SAVAGE4_I2C_SCL_IN 0x00000008
43 #define SAVAGE4_I2C_SDA_IN 0x00000010
45 static void savage4_gpio_setscl(
void *
data,
int val)
59 static void savage4_gpio_setsda(
void *
data,
int val)
73 static int savage4_gpio_getscl(
void *data)
80 static int savage4_gpio_getsda(
void *data)
87 static void prosavage_gpio_setscl(
void* data,
int val)
92 r = VGArCR(chan->
reg, chan->
par);
100 VGAwCR(chan->
reg, r, chan->
par);
103 static void prosavage_gpio_setsda(
void* data,
int val)
108 r = VGArCR(chan->
reg, chan->
par);
116 VGAwCR(chan->
reg, r, chan->
par);
119 static int prosavage_gpio_getscl(
void* data)
126 static int prosavage_gpio_getsda(
void* data)
142 chan->
adapter.dev.parent = &chan->
par->pcidev->dev;
143 chan->
algo.udelay = 10;
144 chan->
algo.timeout = 20;
145 chan->
algo.data = chan;
147 i2c_set_adapdata(&chan->
adapter, chan);
150 chan->
algo.setsda(chan, 1);
151 chan->
algo.setscl(chan, 1);
158 "I2C bus %s registered.\n", name);
161 "Failed to register I2C bus %s.\n", name);
178 par->
chan.algo.setsda = prosavage_gpio_setsda;
179 par->
chan.algo.setscl = prosavage_gpio_setscl;
180 par->
chan.algo.getsda = prosavage_gpio_getsda;
181 par->
chan.algo.getscl = prosavage_gpio_getscl;
185 if (par->
pcidev->revision > 1 && !(VGArCR(0xa6, par) & 0x40))
188 par->
chan.algo.setsda = prosavage_gpio_setsda;
189 par->
chan.algo.setscl = prosavage_gpio_setscl;
190 par->
chan.algo.getsda = prosavage_gpio_getsda;
191 par->
chan.algo.getscl = prosavage_gpio_getscl;
196 par->
chan.algo.setsda = savage4_gpio_setsda;
197 par->
chan.algo.setscl = savage4_gpio_setscl;
198 par->
chan.algo.getsda = savage4_gpio_getsda;
199 par->
chan.algo.getscl = savage4_gpio_getscl;
205 savage_setup_i2c_bus(&par->
chan,
"SAVAGE DDC2");
238 return (edid) ? 0 : 1;