28 #include <linux/module.h>
29 #include <linux/kernel.h>
31 #include <linux/pci.h>
34 #include <linux/i2c.h>
43 #define SCL_DIR_MASK 0x0001
44 #define SCL_DIR 0x0002
45 #define SCL_VAL_MASK 0x0004
46 #define SCL_VAL_OUT 0x0008
47 #define SCL_VAL_IN 0x0010
48 #define SDA_DIR_MASK 0x0100
49 #define SDA_DIR 0x0200
50 #define SDA_VAL_MASK 0x0400
51 #define SDA_VAL_OUT 0x0800
52 #define SDA_VAL_IN 0x1000
54 static void intelfb_gpio_setscl(
void *
data,
int state)
56 struct intelfb_i2c_chan *
chan =
data;
62 val =
INREG(chan->reg);
65 static void intelfb_gpio_setsda(
void *
data,
int state)
67 struct intelfb_i2c_chan *
chan =
data;
73 val =
INREG(chan->reg);
76 static int intelfb_gpio_getscl(
void *
data)
78 struct intelfb_i2c_chan *
chan =
data;
84 val =
INREG(chan->reg);
88 static int intelfb_gpio_getsda(
void *data)
90 struct intelfb_i2c_chan *chan =
data;
96 val =
INREG(chan->reg);
100 static int intelfb_setup_i2c_bus(
struct intelfb_info *dinfo,
101 struct intelfb_i2c_chan *chan,
109 snprintf(chan->adapter.name,
sizeof(chan->adapter.name),
111 chan->adapter.class =
class;
113 chan->adapter.algo_data = &chan->algo;
114 chan->adapter.dev.parent = &chan->dinfo->pdev->dev;
115 chan->algo.setsda = intelfb_gpio_setsda;
116 chan->algo.setscl = intelfb_gpio_setscl;
117 chan->algo.getsda = intelfb_gpio_getsda;
118 chan->algo.getscl = intelfb_gpio_getscl;
119 chan->algo.udelay = 40;
120 chan->algo.timeout = 20;
121 chan->algo.data = chan;
123 i2c_set_adapdata(&chan->adapter, chan);
126 intelfb_gpio_setsda(chan, 1);
127 intelfb_gpio_setscl(chan, 1);
132 DBG_MSG(
"I2C bus %s registered.\n", name);
134 WRN_MSG(
"Failed to register I2C bus %s.\n", name);
147 intelfb_setup_i2c_bus(dinfo, &dinfo->
output[i].ddc_bus,
GPIOA,
162 intelfb_setup_i2c_bus(dinfo, &dinfo->
output[i].ddc_bus,
164 intelfb_setup_i2c_bus(dinfo, &dinfo->
output[i].i2c_bus,
165 GPIOE,
"DVOI2C_E", 0);
178 intelfb_setup_i2c_bus(dinfo, &dinfo->
output[i].i2c_bus,
179 GPIOE,
"SDVOCTRL_E", 0);
200 if (dinfo->
output[i].i2c_bus.dinfo) {
204 if (dinfo->
output[i].ddc_bus.dinfo) {