Lines Matching +full:bus +full:- +full:num

3  * Copyright © 2006-2008,2010 Intel Corporation
27 * Chris Wilson <chris@chris-wilson.co.uk>
31 #include <linux/i2c-algo-bit.h>
44 ret__ = -ETIMEDOUT; \
55 #define GMBUS_REG_READ(reg) ioread32(dev_priv->gmbus_reg + (reg))
56 #define GMBUS_REG_WRITE(reg, val) iowrite32((val), dev_priv->gmbus_reg + (reg))
89 if (!IS_PINEVIEW(dev_priv->dev)) in intel_i2c_quirk_set()
105 struct drm_psb_private *dev_priv = gpio->dev_priv; in get_reserved()
109 reserved = GMBUS_REG_READ(gpio->reg) & in get_reserved()
119 struct drm_psb_private *dev_priv = gpio->dev_priv; in get_clock()
121 GMBUS_REG_WRITE(gpio->reg, reserved | GPIO_CLOCK_DIR_MASK); in get_clock()
122 GMBUS_REG_WRITE(gpio->reg, reserved); in get_clock()
123 return (GMBUS_REG_READ(gpio->reg) & GPIO_CLOCK_VAL_IN) != 0; in get_clock()
129 struct drm_psb_private *dev_priv = gpio->dev_priv; in get_data()
131 GMBUS_REG_WRITE(gpio->reg, reserved | GPIO_DATA_DIR_MASK); in get_data()
132 GMBUS_REG_WRITE(gpio->reg, reserved); in get_data()
133 return (GMBUS_REG_READ(gpio->reg) & GPIO_DATA_VAL_IN) != 0; in get_data()
139 struct drm_psb_private *dev_priv = gpio->dev_priv; in set_clock()
149 GMBUS_REG_WRITE(gpio->reg, reserved | clock_bits); in set_clock()
150 GMBUS_REG_READ(gpio->reg); /* Posting */ in set_clock()
156 struct drm_psb_private *dev_priv = gpio->dev_priv; in set_data()
166 GMBUS_REG_WRITE(gpio->reg, reserved | data_bits); in set_data()
167 GMBUS_REG_READ(gpio->reg); in set_data()
192 gpio->reg = map_pin_to_reg[pin]; in intel_gpio_create()
193 gpio->dev_priv = dev_priv; in intel_gpio_create()
195 snprintf(gpio->adapter.name, sizeof(gpio->adapter.name), in intel_gpio_create()
197 gpio->adapter.owner = THIS_MODULE; in intel_gpio_create()
198 gpio->adapter.algo_data = &gpio->algo; in intel_gpio_create()
199 gpio->adapter.dev.parent = dev_priv->dev.dev; in intel_gpio_create()
200 gpio->algo.setsda = set_data; in intel_gpio_create()
201 gpio->algo.setscl = set_clock; in intel_gpio_create()
202 gpio->algo.getsda = get_data; in intel_gpio_create()
203 gpio->algo.getscl = get_clock; in intel_gpio_create()
204 gpio->algo.udelay = I2C_RISEFALL_TIME; in intel_gpio_create()
205 gpio->algo.timeout = usecs_to_jiffies(2200); in intel_gpio_create()
206 gpio->algo.data = gpio; in intel_gpio_create()
208 if (i2c_bit_add_bus(&gpio->adapter)) in intel_gpio_create()
211 return &gpio->adapter; in intel_gpio_create()
222 int num) in intel_i2c_quirk_xfer() argument
229 gma_intel_i2c_reset(&dev_priv->dev); in intel_i2c_quirk_xfer()
236 ret = adapter->algo->master_xfer(adapter, msgs, num); in intel_i2c_quirk_xfer()
248 int num) in gmbus_xfer() argument
250 struct intel_gmbus *bus = container_of(adapter, in gmbus_xfer() local
253 struct drm_psb_private *dev_priv = adapter->algo_data; in gmbus_xfer()
256 if (bus->force_bit) in gmbus_xfer()
258 bus->force_bit, msgs, num); in gmbus_xfer()
262 GMBUS_REG_WRITE(GMBUS0 + reg_offset, bus->reg0); in gmbus_xfer()
264 for (i = 0; i < num; i++) { in gmbus_xfer()
271 (i + 1 == num ? GMBUS_CYCLE_STOP : 0) | in gmbus_xfer()
289 } while (--len && ++loop < 4); in gmbus_xfer()
297 } while (--len && ++loop < 4); in gmbus_xfer()
301 (i + 1 == num ? GMBUS_CYCLE_STOP : GMBUS_CYCLE_WAIT) | in gmbus_xfer()
318 } while (--len && ++loop < 4); in gmbus_xfer()
325 …if (i + 1 < num && wait_for(GMBUS_REG_READ(GMBUS2 + reg_offset) & (GMBUS_SATOER | GMBUS_HW_WAIT_PH… in gmbus_xfer()
342 /* Mark the GMBUS interface as disabled. We will re-enable it at the in gmbus_xfer()
350 bus->reg0 & 0xff, bus->adapter.name); in gmbus_xfer()
354 bus->force_bit = intel_gpio_create(dev_priv, bus->reg0 & 0xff); in gmbus_xfer()
355 if (!bus->force_bit) in gmbus_xfer()
356 return -ENOMEM; in gmbus_xfer()
358 return intel_i2c_quirk_xfer(dev_priv, bus->force_bit, msgs, num); in gmbus_xfer()
363 struct intel_gmbus *bus = container_of(adapter, in gmbus_func() local
367 if (bus->force_bit) in gmbus_func()
368 bus->force_bit->algo->functionality(bus->force_bit); in gmbus_func()
382 * gma_intel_setup_gmbus() - instantiate all Intel i2c GMBuses
400 dev_priv->gmbus = kcalloc(GMBUS_NUM_PORTS, sizeof(struct intel_gmbus), in gma_intel_setup_gmbus()
402 if (dev_priv->gmbus == NULL) in gma_intel_setup_gmbus()
403 return -ENOMEM; in gma_intel_setup_gmbus()
406 dev_priv->gmbus_reg = dev_priv->aux_reg; in gma_intel_setup_gmbus()
408 dev_priv->gmbus_reg = dev_priv->vdc_reg; in gma_intel_setup_gmbus()
411 struct intel_gmbus *bus = &dev_priv->gmbus[i]; in gma_intel_setup_gmbus() local
413 bus->adapter.owner = THIS_MODULE; in gma_intel_setup_gmbus()
414 snprintf(bus->adapter.name, in gma_intel_setup_gmbus()
415 sizeof(bus->adapter.name), in gma_intel_setup_gmbus()
419 bus->adapter.dev.parent = dev->dev; in gma_intel_setup_gmbus()
420 bus->adapter.algo_data = dev_priv; in gma_intel_setup_gmbus()
422 bus->adapter.algo = &gmbus_algorithm; in gma_intel_setup_gmbus()
423 ret = i2c_add_adapter(&bus->adapter); in gma_intel_setup_gmbus()
428 bus->reg0 = i | GMBUS_RATE_100KHZ; in gma_intel_setup_gmbus()
431 bus->force_bit = intel_gpio_create(dev_priv, i); in gma_intel_setup_gmbus()
434 gma_intel_i2c_reset(&dev_priv->dev); in gma_intel_setup_gmbus()
439 while (i--) { in gma_intel_setup_gmbus()
440 struct intel_gmbus *bus = &dev_priv->gmbus[i]; in gma_intel_setup_gmbus() local
441 i2c_del_adapter(&bus->adapter); in gma_intel_setup_gmbus()
443 kfree(dev_priv->gmbus); in gma_intel_setup_gmbus()
444 dev_priv->gmbus = NULL; in gma_intel_setup_gmbus()
450 struct intel_gmbus *bus = to_intel_gmbus(adapter); in gma_intel_gmbus_set_speed() local
458 bus->reg0 = (bus->reg0 & ~(0x3 << 8)) | (speed << 8); in gma_intel_gmbus_set_speed()
463 struct intel_gmbus *bus = to_intel_gmbus(adapter); in gma_intel_gmbus_force_bit() local
466 if (bus->force_bit == NULL) { in gma_intel_gmbus_force_bit()
467 struct drm_psb_private *dev_priv = adapter->algo_data; in gma_intel_gmbus_force_bit()
468 bus->force_bit = intel_gpio_create(dev_priv, in gma_intel_gmbus_force_bit()
469 bus->reg0 & 0xff); in gma_intel_gmbus_force_bit()
472 if (bus->force_bit) { in gma_intel_gmbus_force_bit()
473 i2c_del_adapter(bus->force_bit); in gma_intel_gmbus_force_bit()
474 kfree(bus->force_bit); in gma_intel_gmbus_force_bit()
475 bus->force_bit = NULL; in gma_intel_gmbus_force_bit()
485 if (dev_priv->gmbus == NULL) in gma_intel_teardown_gmbus()
489 struct intel_gmbus *bus = &dev_priv->gmbus[i]; in gma_intel_teardown_gmbus() local
490 if (bus->force_bit) { in gma_intel_teardown_gmbus()
491 i2c_del_adapter(bus->force_bit); in gma_intel_teardown_gmbus()
492 kfree(bus->force_bit); in gma_intel_teardown_gmbus()
494 i2c_del_adapter(&bus->adapter); in gma_intel_teardown_gmbus()
497 dev_priv->gmbus_reg = NULL; /* iounmap is done in driver_unload */ in gma_intel_teardown_gmbus()
498 kfree(dev_priv->gmbus); in gma_intel_teardown_gmbus()
499 dev_priv->gmbus = NULL; in gma_intel_teardown_gmbus()