29 #include <linux/module.h>
30 #include <linux/i2c.h>
38 #define _wait_for(COND, MS, W) ({ \
39 unsigned long timeout__ = jiffies + msecs_to_jiffies(MS); \
42 if (time_after(jiffies, timeout__)) { \
46 if (W && !(in_atomic() || in_dbg_master())) msleep(W); \
51 #define wait_for(COND, MS) _wait_for(COND, MS, 1)
52 #define wait_for_atomic(COND, MS) _wait_for(COND, MS, 0)
56 #define I2C_RISEFALL_TIME 20
123 static int get_data(
void *data)
128 u32 reserved = get_reserved(gpio);
134 static void set_clock(
void *data,
int state_high)
139 u32 reserved = get_reserved(gpio);
152 static void set_data(
void *data,
int state_high)
157 u32 reserved = get_reserved(gpio);
173 static const int map_pin_to_reg[] = {
185 if (pin >=
ARRAY_SIZE(map_pin_to_reg) || !map_pin_to_reg[pin])
192 gpio->
reg = map_pin_to_reg[
pin];
196 "gma500 GPIO%c",
"?BACDE?F"[pin]);
199 gpio->
adapter.dev.parent = &dev_priv->
dev->pdev->dev;
200 gpio->
algo.setsda = set_data;
201 gpio->
algo.setscl = set_clock;
202 gpio->
algo.getsda = get_data;
231 intel_i2c_quirk_set(dev_priv,
true);
236 ret = adapter->
algo->master_xfer(adapter, msgs, num);
240 intel_i2c_quirk_set(dev_priv,
false);
258 return intel_i2c_quirk_xfer(dev_priv,
265 for (i = 0; i < num; i++) {
288 }
while (--len && ++loop < 4);
295 val |= *buf++ << (8 * loop);
296 }
while (--len && ++loop < 4);
314 val |= *buf++ << (8 * loop);
315 }
while (--len && ++loop < 4);
346 DRM_INFO(
"GMBUS timed out, falling back to bit banging on pin %d [%s]\n",
351 bus->
force_bit = intel_gpio_create(dev_priv, bus->
reg0 & 0xff);
355 return intel_i2c_quirk_xfer(dev_priv, bus->
force_bit, msgs, num);
374 .master_xfer = gmbus_xfer,
375 .functionality = gmbus_func
412 bus->
adapter.dev.parent = &dev->pdev->dev;
415 bus->
adapter.algo = &gmbus_algorithm;
424 bus->
force_bit = intel_gpio_create(dev_priv, i);
451 bus->
reg0 = (bus->
reg0 & ~(0x3 << 8)) | (speed << 8);
461 bus->
force_bit = intel_gpio_create(dev_priv,