linux/drivers/gpu/drm/i915/intel_i2c.c
/**
 * intel_gmbus_setup - instantiate all Intel i2c GMBuses
 * @dev_priv: i915 device private
 */
instantiate all Intel i2c GMBuses
@dev_priv: i915 device private
instantiate all Intel i2c GMBuses @dev_priv : i915 device private
int intel_setup_gmbus(struct drm_i915_private *dev_priv)
{
	struct pci_dev *pdev = dev_priv->drm.pdev;
	struct intel_gmbus *bus;
	unsigned int pin;
	int ret;
	if (INTEL_INFO(dev_priv)->num_pipes == 0)
		return 0;
	if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv))
		dev_priv->gpio_mmio_base = VLV_DISPLAY_BASE;
	else if (!HAS_GMCH_DISPLAY(dev_priv))
		dev_priv->gpio_mmio_base =
			i915_mmio_reg_offset(PCH_GPIOA) -
			i915_mmio_reg_offset(GPIOA);
	mutex_init(&dev_priv->gmbus_mutex);
	init_waitqueue_head(&dev_priv->gmbus_wait_queue);
	for (pin = 0; pin < ARRAY_SIZE(dev_priv->gmbus); pin++) {
		if (!intel_gmbus_is_valid_pin(dev_priv, pin))
			continue;
		bus = &dev_priv->gmbus[pin];
		bus->adapter.owner = THIS_MODULE;
		bus->adapter.class = I2C_CLASS_DDC;
		snprintf(bus->adapter.name,
			 sizeof(bus->adapter.name),
			 "i915 gmbus %s",
			 get_gmbus_pin(dev_priv, pin)->name);
		bus->adapter.dev.parent = &pdev->dev;
		bus->dev_priv = dev_priv;
		bus->adapter.algo = &gmbus_algorithm;
		bus->adapter.lock_ops = &gmbus_lock_ops;
		bus->adapter.retries = 1;
		bus->reg0 = pin | GMBUS_RATE_100KHZ;
		if (IS_I830(dev_priv))
			bus->force_bit = 1;
		intel_gpio_setup(bus, pin);
		ret = i2c_add_adapter(&bus->adapter);
		if (ret)
			goto err;
	}
	intel_i2c_reset(dev_priv);
	return 0;
err:
	while (pin--) {
		if (!intel_gmbus_is_valid_pin(dev_priv, pin))
			continue;
		bus = &dev_priv->gmbus[pin];
		i2c_del_adapter(&bus->adapter);
	}
	return ret;
}
int intel_setup_gmbus ( struct drm_i915_private * dev_priv ) { struct pci_dev * pdev = dev_priv -> drm . pdev ; struct intel_gmbus * bus ; unsigned int pin ; int ret ; if ( INTEL_INFO ( dev_priv ) -> num_pipes == 0 ) return 0 ; if ( IS_VALLEYVIEW ( dev_priv ) || IS_CHERRYVIEW ( dev_priv ) ) dev_priv -> gpio_mmio_base = VLV_DISPLAY_BASE ; else if ( ! HAS_GMCH_DISPLAY ( dev_priv ) ) dev_priv -> gpio_mmio_base = i915_mmio_reg_offset ( PCH_GPIOA ) - i915_mmio_reg_offset ( GPIOA ) ; mutex_init ( & dev_priv -> gmbus_mutex ) ; init_waitqueue_head ( & dev_priv -> gmbus_wait_queue ) ; for ( pin = 0 ; pin < ARRAY_SIZE ( dev_priv -> gmbus ) ; pin ++ ) { if ( ! intel_gmbus_is_valid_pin ( dev_priv , pin ) ) continue ; bus = & dev_priv -> gmbus [ pin ] ; bus -> adapter . owner = THIS_MODULE ; bus -> adapter . class = I2C_CLASS_DDC ; snprintf ( bus -> adapter . name , sizeof ( bus -> adapter . name ) , " " , get_gmbus_pin ( dev_priv , pin ) -> name ) ; bus -> adapter . dev . parent = & pdev -> dev ; bus -> dev_priv = dev_priv ; bus -> adapter . algo = & gmbus_algorithm ; bus -> adapter . lock_ops = & gmbus_lock_ops ; bus -> adapter . retries = 1 ; bus -> reg0 = pin | GMBUS_RATE_100KHZ ; if ( IS_I830 ( dev_priv ) ) bus -> force_bit = 1 ; intel_gpio_setup ( bus , pin ) ; ret = i2c_add_adapter ( & bus -> adapter ) ; if ( ret ) goto err ; } intel_i2c_reset ( dev_priv ) ; return 0 ; err : while ( pin -- ) { if ( ! intel_gmbus_is_valid_pin ( dev_priv , pin ) ) continue ; bus = & dev_priv -> gmbus [ pin ] ; i2c_del_adapter ( & bus -> adapter ) ; } return ret ; }
intel_gmbus_setup - instantiate all Intel i2c GMBuses
 @dev_priv: i915 device private
intel_gmbus_setup - instantiate all Intel i2c GMBuses @dev_priv : i915 device private
/*
		 * We wish to retry with bit banging
		 * after a timed out GMBUS attempt.
		 */ /* By default use a conservative clock rate */ /* gmbus seems to be broken on i830 */