• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ i2c_new_dummy函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中i2c_new_dummy函数的典型用法代码示例。如果您正苦于以下问题:C++ i2c_new_dummy函数的具体用法?C++ i2c_new_dummy怎么用?C++ i2c_new_dummy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了i2c_new_dummy函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: max8925_probe

static int __devinit max8925_probe(struct i2c_client *client,
				   const struct i2c_device_id *id)
{
	struct max8925_platform_data *pdata = client->dev.platform_data;
	static struct max8925_chip *chip;

	if (!pdata) {
		pr_info("%s: platform data is missing\n", __func__);
		return -EINVAL;
	}

	chip = kzalloc(sizeof(struct max8925_chip), GFP_KERNEL);
	if (chip == NULL)
		return -ENOMEM;
	chip->i2c = client;
	chip->dev = &client->dev;
	i2c_set_clientdata(client, chip);
	dev_set_drvdata(chip->dev, chip);
	mutex_init(&chip->io_lock);

	chip->rtc = i2c_new_dummy(chip->i2c->adapter, RTC_I2C_ADDR);
	i2c_set_clientdata(chip->rtc, chip);

	chip->adc = i2c_new_dummy(chip->i2c->adapter, ADC_I2C_ADDR);
	i2c_set_clientdata(chip->adc, chip);

	max8925_device_init(chip, pdata);

	return 0;
}
开发者ID:CSCLOG,项目名称:beaglebone,代码行数:30,代码来源:max8925-i2c.c


示例2: pm800_pages_init

static int pm800_pages_init(struct pm80x_chip *chip)
{
	struct pm80x_subchip *subchip;
	struct i2c_client *client = chip->client;

	subchip = chip->subchip;
	/* PM800 block power: i2c addr 0x31 */
	if (subchip->power_page_addr) {
		subchip->power_page =
		    i2c_new_dummy(client->adapter, subchip->power_page_addr);
		subchip->regmap_power =
		    devm_regmap_init_i2c(subchip->power_page,
					 &pm80x_regmap_config);
		i2c_set_clientdata(subchip->power_page, chip);
	} else
		dev_info(chip->dev,
			 "PM800 block power 0x31: No power_page_addr\n");

	/* PM800 block GPADC: i2c addr 0x32 */
	if (subchip->gpadc_page_addr) {
		subchip->gpadc_page = i2c_new_dummy(client->adapter,
						    subchip->gpadc_page_addr);
		subchip->regmap_gpadc =
		    devm_regmap_init_i2c(subchip->gpadc_page,
					 &pm80x_regmap_config);
		i2c_set_clientdata(subchip->gpadc_page, chip);
	} else
		dev_info(chip->dev,
			 "PM800 block GPADC 0x32: No gpadc_page_addr\n");

	return 0;
}
开发者ID:AmesianX,项目名称:netlink-mmap,代码行数:32,代码来源:88pm800.c


示例3: max8997_i2c_probe

static int max8997_i2c_probe(struct i2c_client *i2c,
			    const struct i2c_device_id *id)
{
	struct max8997_dev *max8997;
	struct max8997_platform_data *pdata = i2c->dev.platform_data;
	int ret = 0;

	max8997 = kzalloc(sizeof(struct max8997_dev), GFP_KERNEL);
	if (max8997 == NULL)
		return -ENOMEM;

	i2c_set_clientdata(i2c, max8997);
	max8997->dev = &i2c->dev;
	max8997->i2c = i2c;
	max8997->type = id->driver_data;
	max8997->irq = i2c->irq;

	if (!pdata)
		goto err;

	max8997->irq_base = pdata->irq_base;
	max8997->ono = pdata->ono;
	max8997->wakeup = pdata->wakeup;

	mutex_init(&max8997->iolock);

	max8997->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC);
	i2c_set_clientdata(max8997->rtc, max8997);
	max8997->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
	i2c_set_clientdata(max8997->haptic, max8997);
	max8997->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
	i2c_set_clientdata(max8997->muic, max8997);

	pm_runtime_set_active(max8997->dev);

	max8997_irq_init(max8997);

	mfd_add_devices(max8997->dev, -1, max8997_devs,
			ARRAY_SIZE(max8997_devs),
			NULL, 0);

	/*
	 * TODO: enable others (flash, muic, rtc, battery, ...) and
	 * check the return value
	 */

	if (ret < 0)
		goto err_mfd;

	return ret;

err_mfd:
	mfd_remove_devices(max8997->dev);
	i2c_unregister_device(max8997->muic);
	i2c_unregister_device(max8997->haptic);
	i2c_unregister_device(max8997->rtc);
err:
	kfree(max8997);
	return ret;
}
开发者ID:303750856,项目名称:linux-3.1,代码行数:60,代码来源:max8997.c


示例4: sfe4001_init

/* This board uses an I2C expander to provider power to the PHY, which needs to
 * be turned on before the PHY can be used.
 * Context: Process context, rtnl lock held
 */
static int sfe4001_init(struct efx_nic *efx)
{
	struct falcon_board *board = falcon_board(efx);
	int rc;

#if defined(CONFIG_SENSORS_LM90) || defined(CONFIG_SENSORS_LM90_MODULE)
	board->hwmon_client =
		i2c_new_device(&board->i2c_adap, &sfe4001_hwmon_info);
#else
	board->hwmon_client =
		i2c_new_dummy(&board->i2c_adap, sfe4001_hwmon_info.addr);
#endif
	if (!board->hwmon_client)
		return -EIO;

	/* Raise board/PHY high limit from 85 to 90 degrees Celsius */
	rc = i2c_smbus_write_byte_data(board->hwmon_client,
				       MAX664X_REG_WLHO, 90);
	if (rc)
		goto fail_hwmon;

	board->ioexp_client = i2c_new_dummy(&board->i2c_adap, PCA9539);
	if (!board->ioexp_client) {
		rc = -EIO;
		goto fail_hwmon;
	}

	if (efx->phy_mode & PHY_MODE_SPECIAL) {
		/* PHY won't generate a 156.25 MHz clock and MAC stats fetch
		 * will fail. */
		falcon_stop_nic_stats(efx);
	}
	rc = sfe4001_poweron(efx);
	if (rc)
		goto fail_ioexp;

	rc = device_create_file(&efx->pci_dev->dev, &dev_attr_phy_flash_cfg);
	if (rc)
		goto fail_on;

	EFX_INFO(efx, "PHY is powered on\n");
	return 0;

fail_on:
	sfe4001_poweroff(efx);
fail_ioexp:
	i2c_unregister_device(board->ioexp_client);
fail_hwmon:
	i2c_unregister_device(board->hwmon_client);
	return rc;
}
开发者ID:A2109devs,项目名称:lenovo_a2109a_kernel,代码行数:55,代码来源:falcon_boards.c


示例5: max77843_chg_init

/* Charger and Charger regulator use same regmap. */
static int max77843_chg_init(struct max77843 *max77843)
{
	int ret;

	max77843->i2c_chg = i2c_new_dummy(max77843->i2c->adapter, I2C_ADDR_CHG);
	if (!max77843->i2c_chg) {
		dev_err(&max77843->i2c->dev,
				"Cannot allocate I2C device for Charger\n");
		return PTR_ERR(max77843->i2c_chg);
	}
	i2c_set_clientdata(max77843->i2c_chg, max77843);

	max77843->regmap_chg = devm_regmap_init_i2c(max77843->i2c_chg,
			&max77843_charger_regmap_config);
	if (IS_ERR(max77843->regmap_chg)) {
		ret = PTR_ERR(max77843->regmap_chg);
		goto err_chg_i2c;
	}

	return 0;

err_chg_i2c:
	i2c_unregister_device(max77843->i2c_chg);

	return ret;
}
开发者ID:19Dan01,项目名称:linux,代码行数:27,代码来源:max77843.c


示例6: max77686_i2c_probe

static int max77686_i2c_probe(struct i2c_client *i2c,
			      const struct i2c_device_id *id)
{
	struct max77686_dev *max77686 = NULL;
	struct max77686_platform_data *pdata = dev_get_platdata(&i2c->dev);
	unsigned int data;
	int ret = 0;

	if (i2c->dev.of_node)
		pdata = max77686_i2c_parse_dt_pdata(&i2c->dev);

	if (!pdata) {
		dev_err(&i2c->dev, "No platform data found.\n");
		return -EIO;
	}

	max77686 = devm_kzalloc(&i2c->dev,
				sizeof(struct max77686_dev), GFP_KERNEL);
	if (max77686 == NULL)
		return -ENOMEM;

	i2c_set_clientdata(i2c, max77686);
	max77686->dev = &i2c->dev;
	max77686->i2c = i2c;
	max77686->type = id->driver_data;

	max77686->wakeup = pdata->wakeup;
	max77686->irq_gpio = pdata->irq_gpio;
	max77686->irq = i2c->irq;

	max77686->regmap = devm_regmap_init_i2c(i2c, &max77686_regmap_config);
	if (IS_ERR(max77686->regmap)) {
		ret = PTR_ERR(max77686->regmap);
		dev_err(max77686->dev, "Failed to allocate register map: %d\n",
				ret);
		return ret;
	}

	if (regmap_read(max77686->regmap,
			 MAX77686_REG_DEVICE_ID, &data) < 0) {
		dev_err(max77686->dev,
			"device not found on this channel (this is not an error)\n");
		return -ENODEV;
	} else
		dev_info(max77686->dev, "device found\n");

	max77686->rtc = i2c_new_dummy(i2c->adapter, I2C_ADDR_RTC);
	i2c_set_clientdata(max77686->rtc, max77686);

	max77686_irq_init(max77686);

	ret = mfd_add_devices(max77686->dev, -1, max77686_devs,
			      ARRAY_SIZE(max77686_devs), NULL, 0, NULL);
	if (ret < 0) {
		mfd_remove_devices(max77686->dev);
		i2c_unregister_device(max77686->rtc);
	}

	return ret;
}
开发者ID:BozkurTR,项目名称:kernel,代码行数:60,代码来源:max77686.c


示例7: max8998_i2c_probe

static int max8998_i2c_probe(struct i2c_client *i2c,
			    const struct i2c_device_id *id)
{
	struct max8998_platform_data *pdata = i2c->dev.platform_data;
	struct max8998_dev *max8998;
	int ret = 0;

	max8998 = kzalloc(sizeof(struct max8998_dev), GFP_KERNEL);
	if (max8998 == NULL)
		return -ENOMEM;

	i2c_set_clientdata(i2c, max8998);
	max8998->dev = &i2c->dev;
	max8998->i2c = i2c;
	max8998->irq = i2c->irq;
	max8998->type = id->driver_data;
	if (pdata) {
		max8998->ono = pdata->ono;
		max8998->irq_base = pdata->irq_base;
		max8998->wakeup = pdata->wakeup;
	}
	mutex_init(&max8998->iolock);

	max8998->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
	i2c_set_clientdata(max8998->rtc, max8998);

	max8998_irq_init(max8998);

	pm_runtime_set_active(max8998->dev);

	switch (id->driver_data) {
	case TYPE_LP3974:
		ret = mfd_add_devices(max8998->dev, -1,
				lp3974_devs, ARRAY_SIZE(lp3974_devs),
				NULL, 0);
		break;
	case TYPE_MAX8998:
		ret = mfd_add_devices(max8998->dev, -1,
				max8998_devs, ARRAY_SIZE(max8998_devs),
				NULL, 0);
		break;
	default:
		ret = -EINVAL;
	}

	if (ret < 0)
		goto err;

	return ret;

err:
	mfd_remove_devices(max8998->dev);
	max8998_irq_exit(max8998);
	i2c_unregister_device(max8998->rtc);
	kfree(max8998);
	return ret;
}
开发者ID:119-org,项目名称:hi3518-osdrv,代码行数:57,代码来源:max8998.c


示例8: s5m87xx_i2c_probe

static int s5m87xx_i2c_probe(struct i2c_client *i2c,
			    const struct i2c_device_id *id)
{
	struct s5m_platform_data *pdata = i2c->dev.platform_data;
	struct s5m87xx_dev *s5m87xx;
	int ret = 0;

	if (!pdata)
		return -EINVAL;

	s5m87xx = kzalloc(sizeof(struct s5m87xx_dev), GFP_KERNEL);
	if (s5m87xx == NULL)
		return -ENOMEM;

	i2c_set_clientdata(i2c, s5m87xx);
	s5m87xx->dev = &i2c->dev;
	s5m87xx->i2c = i2c;
	s5m87xx->irq = gpio_to_irq(pdata->irq_gpio);
	s5m87xx->type = id->driver_data;

	if (pdata) {
		s5m87xx->device_type = pdata->device_type;
		s5m87xx->ono = pdata->ono;
		s5m87xx->irq_base = pdata->irq_base;
		s5m87xx->wakeup = pdata->wakeup;
	}

	mutex_init(&s5m87xx->iolock);

	s5m87xx->rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
	i2c_set_clientdata(s5m87xx->rtc, s5m87xx);

	if (pdata && pdata->cfg_pmic_irq)
		pdata->cfg_pmic_irq();

	s5m_irq_init(s5m87xx);

	pm_runtime_set_active(s5m87xx->dev);

	ret = mfd_add_devices(s5m87xx->dev, -1,
				s5m87xx_devs, ARRAY_SIZE(s5m87xx_devs),
				NULL, 0);

	if (ret < 0)
		goto err;

	dev_info(s5m87xx->dev ,"S5M87xx MFD probe done!!! \n");
	return ret;

err:
	mfd_remove_devices(s5m87xx->dev);
	s5m_irq_exit(s5m87xx);
	i2c_unregister_device(s5m87xx->rtc);
	kfree(s5m87xx);
	return ret;
}
开发者ID:DerTeufel,项目名称:SGS3-Sourcedrops,代码行数:56,代码来源:s5m-core.c


示例9: pm860x_probe

static int __devinit pm860x_probe(struct i2c_client *client,
				  const struct i2c_device_id *id)
{
	struct pm860x_platform_data *pdata = client->dev.platform_data;
	struct pm860x_chip *chip;
	int ret;

	if (!pdata) {
		pr_info("No platform data in %s!\n", __func__);
		return -EINVAL;
	}

	chip = kzalloc(sizeof(struct pm860x_chip), GFP_KERNEL);
	if (chip == NULL)
		return -ENOMEM;

	chip->id = verify_addr(client);
	chip->regmap = regmap_init_i2c(client, &pm860x_regmap_config);
	if (IS_ERR(chip->regmap)) {
		ret = PTR_ERR(chip->regmap);
		dev_err(&client->dev, "Failed to allocate register map: %d\n",
				ret);
		kfree(chip);
		return ret;
	}
	chip->client = client;
	i2c_set_clientdata(client, chip);
	chip->dev = &client->dev;
	dev_set_drvdata(chip->dev, chip);

	/*
	 * Both client and companion client shares same platform driver.
	 * Driver distinguishes them by pdata->companion_addr.
	 * pdata->companion_addr is only assigned if companion chip exists.
	 * At the same time, the companion_addr shouldn't equal to client
	 * address.
	 */
	if (pdata->companion_addr && (pdata->companion_addr != client->addr)) {
		chip->companion_addr = pdata->companion_addr;
		chip->companion = i2c_new_dummy(chip->client->adapter,
						chip->companion_addr);
		chip->regmap_companion = regmap_init_i2c(chip->companion,
							&pm860x_regmap_config);
		if (IS_ERR(chip->regmap_companion)) {
			ret = PTR_ERR(chip->regmap_companion);
			dev_err(&chip->companion->dev,
				"Failed to allocate register map: %d\n", ret);
			return ret;
		}
		i2c_set_clientdata(chip->companion, chip);
	}

	pm860x_device_init(chip, pdata);
	return 0;
}
开发者ID:33d,项目名称:linux-2.6.21-hh20,代码行数:55,代码来源:88pm860x-i2c.c


示例10: bcm590xx_i2c_probe

static int bcm590xx_i2c_probe(struct i2c_client *i2c_pri,
                              const struct i2c_device_id *id)
{
    struct bcm590xx *bcm590xx;
    int ret;

    bcm590xx = devm_kzalloc(&i2c_pri->dev, sizeof(*bcm590xx), GFP_KERNEL);
    if (!bcm590xx)
        return -ENOMEM;

    i2c_set_clientdata(i2c_pri, bcm590xx);
    bcm590xx->dev = &i2c_pri->dev;
    bcm590xx->i2c_pri = i2c_pri;

    bcm590xx->regmap_pri = devm_regmap_init_i2c(i2c_pri,
                           &bcm590xx_regmap_config_pri);
    if (IS_ERR(bcm590xx->regmap_pri)) {
        ret = PTR_ERR(bcm590xx->regmap_pri);
        dev_err(&i2c_pri->dev, "primary regmap init failed: %d\n", ret);
        return ret;
    }

    /* Secondary I2C slave address is the base address with A(2) asserted */
    bcm590xx->i2c_sec = i2c_new_dummy(i2c_pri->adapter,
                                      i2c_pri->addr | BIT(2));
    if (IS_ERR_OR_NULL(bcm590xx->i2c_sec)) {
        dev_err(&i2c_pri->dev, "failed to add secondary I2C device\n");
        return -ENODEV;
    }
    i2c_set_clientdata(bcm590xx->i2c_sec, bcm590xx);

    bcm590xx->regmap_sec = devm_regmap_init_i2c(bcm590xx->i2c_sec,
                           &bcm590xx_regmap_config_sec);
    if (IS_ERR(bcm590xx->regmap_sec)) {
        ret = PTR_ERR(bcm590xx->regmap_sec);
        dev_err(&bcm590xx->i2c_sec->dev,
                "secondary regmap init failed: %d\n", ret);
        goto err;
    }

    ret = mfd_add_devices(&i2c_pri->dev, -1, bcm590xx_devs,
                          ARRAY_SIZE(bcm590xx_devs), NULL, 0, NULL);
    if (ret < 0) {
        dev_err(&i2c_pri->dev, "failed to add sub-devices: %d\n", ret);
        goto err;
    }

    return 0;

err:
    i2c_unregister_device(bcm590xx->i2c_sec);
    return ret;
}
开发者ID:raoy1990,项目名称:linux,代码行数:53,代码来源:bcm590xx.c


示例11: si_8348_init

int si_8348_init(void)
{
	struct i2c_client *client;
	int idx;
	int ret = -EFAULT;

	pr_info("%s driver starting!!\n", MHL_DRIVER_NAME);

#if 0
	/* "Hotplug" the MHL transmitter device onto the 2nd I2C bus */
	i2c_bus_adapter = i2c_get_adapter(HDMI_I2C_CHANNEL);
	if (i2c_bus_adapter == NULL) {
		pr_err("%s() failed to get i2c adapter\n", __func__);
		goto done;
	}

	for (idx = 0; idx < ARRAY_SIZE(device_addresses); idx++) {
		if (idx == 0) {
			client = i2c_new_device(i2c_bus_adapter, &si_8348_i2c_boardinfo[idx]);
			device_addresses[idx].client = client;
		} else {
			device_addresses[idx].client = i2c_new_dummy(i2c_bus_adapter,
								     device_addresses[idx].
								     dev_addr);
		}
		/* TODO: FD, TBC, device_addresses should be initialized with care... */
		if (device_addresses[idx].client == NULL) {
			pr_err("[ERROR] %s():%d failed !\n", __func__, __LINE__);
			goto err_exit;
		}
	}

	ret = i2c_add_driver(&si_8348_mhl_tx_i2c_driver);
	if (ret < 0) {
		pr_info("[ERROR] %s():%d failed !\n", __func__, __LINE__);
		goto err_exit;
	}

	goto done;

 err_exit:
/*
	for (idx = 0; idx < ARRAY_SIZE(device_addresses); idx++) {
		if (device_addresses[idx].client != NULL)
			i2c_unregister_device(device_addresses[idx].client);
	}
*/
 done:
	MHL_TX_DBG_INFO(dev_context, "returning %d\n", ret);
#endif
	return ret;
}
开发者ID:Swapnil133609,项目名称:Zeus_exp,代码行数:52,代码来源:platform.c


示例12: max8907c_i2c_probe

static int max8907c_i2c_probe(struct i2c_client *i2c,
			      const struct i2c_device_id *id)
{
	struct max8907c *max8907c;
	struct max8907c_platform_data *pdata = i2c->dev.platform_data;
	int ret;
	int i;

	max8907c = kzalloc(sizeof(struct max8907c), GFP_KERNEL);
	if (max8907c == NULL)
		return -ENOMEM;

	max8907c->dev = &i2c->dev;
	dev_set_drvdata(max8907c->dev, max8907c);

	max8907c->i2c_power = i2c;
	i2c_set_clientdata(i2c, max8907c);

	max8907c->i2c_rtc = i2c_new_dummy(i2c->adapter, RTC_I2C_ADDR);
	i2c_set_clientdata(max8907c->i2c_rtc, max8907c);

	mutex_init(&max8907c->io_lock);

	for (i = 0; i < ARRAY_SIZE(cells); i++) {
		cells[i].platform_data = max8907c;
		cells[i].pdata_size = sizeof(*max8907c);
	}
	ret = mfd_add_devices(max8907c->dev, -1, cells, ARRAY_SIZE(cells),
			      NULL, 0);
	if (ret != 0) {
	  	i2c_unregister_device(max8907c->i2c_rtc);
		kfree(max8907c);
		pr_debug("max8907c: failed to add MFD devices   %X\n", ret);
		return ret;
	}

	max8907c_client = i2c;

	max8907c_irq_init(max8907c, i2c->irq, pdata->irq_base);

	ret = max8097c_add_subdevs(max8907c, pdata);

	if (pdata->use_power_off && !pm_power_off)
		pm_power_off = max8907c_power_off;

	if (pdata->max8907c_setup)
		return pdata->max8907c_setup();

	return ret;
}
开发者ID:AndroidDeveloperAlliance,项目名称:ZenKernel_Grouper,代码行数:50,代码来源:max8907c.c


示例13: pm860x_probe

static int __devinit pm860x_probe(struct i2c_client *client,
				  const struct i2c_device_id *id)
{
	struct pm860x_platform_data *pdata = client->dev.platform_data;
	struct pm860x_chip *chip;

	if (!pdata) {
		pr_info("No platform data in %s!\n", __func__);
		return -EINVAL;
	}

	chip = kzalloc(sizeof(struct pm860x_chip), GFP_KERNEL);
	if (chip == NULL)
		return -ENOMEM;

	chip->id = verify_addr(client);
	chip->client = client;
	i2c_set_clientdata(client, chip);
	chip->dev = &client->dev;
	mutex_init(&chip->io_lock);
	dev_set_drvdata(chip->dev, chip);

	/*
	 * Both client and companion client shares same platform driver.
	 * Driver distinguishes them by pdata->companion_addr.
	 * pdata->companion_addr is only assigned if companion chip exists.
	 * At the same time, the companion_addr shouldn't equal to client
	 * address.
	 */
	if (pdata->companion_addr && (pdata->companion_addr != client->addr)) {
		chip->companion_addr = pdata->companion_addr;
		chip->companion = i2c_new_dummy(chip->client->adapter,
						chip->companion_addr);
		i2c_set_clientdata(chip->companion, chip);
	}

	pm860x_device_init(chip, pdata);
	return 0;
}
开发者ID:KaZoom,项目名称:buildroot-linux-kernel-m3,代码行数:39,代码来源:88pm860x-i2c.c


示例14: max77693_i2c_probe

static int max77693_i2c_probe(struct i2c_client *i2c,
			      const struct i2c_device_id *id)
{
	struct max77693_dev *max77693;
	unsigned int reg_data;
	int ret = 0;

	max77693 = devm_kzalloc(&i2c->dev,
			sizeof(struct max77693_dev), GFP_KERNEL);
	if (max77693 == NULL)
		return -ENOMEM;

	i2c_set_clientdata(i2c, max77693);
	max77693->dev = &i2c->dev;
	max77693->i2c = i2c;
	max77693->irq = i2c->irq;
	max77693->type = id->driver_data;

	max77693->regmap = devm_regmap_init_i2c(i2c, &max77693_regmap_config);
	if (IS_ERR(max77693->regmap)) {
		ret = PTR_ERR(max77693->regmap);
		dev_err(max77693->dev, "failed to allocate register map: %d\n",
				ret);
		return ret;
	}

	ret = regmap_read(max77693->regmap, MAX77693_PMIC_REG_PMIC_ID2,
				&reg_data);
	if (ret < 0) {
		dev_err(max77693->dev, "device not found on this channel\n");
		return ret;
	} else
		dev_info(max77693->dev, "device ID: 0x%x\n", reg_data);

	max77693->muic = i2c_new_dummy(i2c->adapter, I2C_ADDR_MUIC);
	if (!max77693->muic) {
		dev_err(max77693->dev, "Failed to allocate I2C device for MUIC\n");
		return -ENODEV;
	}
	i2c_set_clientdata(max77693->muic, max77693);

	max77693->haptic = i2c_new_dummy(i2c->adapter, I2C_ADDR_HAPTIC);
	if (!max77693->haptic) {
		dev_err(max77693->dev, "Failed to allocate I2C device for Haptic\n");
		ret = -ENODEV;
		goto err_i2c_haptic;
	}
	i2c_set_clientdata(max77693->haptic, max77693);

	max77693->regmap_haptic = devm_regmap_init_i2c(max77693->haptic,
					&max77693_regmap_haptic_config);
	if (IS_ERR(max77693->regmap_haptic)) {
		ret = PTR_ERR(max77693->regmap_haptic);
		dev_err(max77693->dev,
			"failed to initialize haptic register map: %d\n", ret);
		goto err_regmap;
	}

	/*
	 * Initialize register map for MUIC device because use regmap-muic
	 * instance of MUIC device when irq of max77693 is initialized
	 * before call max77693-muic probe() function.
	 */
	max77693->regmap_muic = devm_regmap_init_i2c(max77693->muic,
					 &max77693_regmap_muic_config);
	if (IS_ERR(max77693->regmap_muic)) {
		ret = PTR_ERR(max77693->regmap_muic);
		dev_err(max77693->dev,
			"failed to allocate register map: %d\n", ret);
		goto err_regmap;
	}

	ret = regmap_add_irq_chip(max77693->regmap, max77693->irq,
				IRQF_ONESHOT | IRQF_SHARED |
				IRQF_TRIGGER_FALLING, 0,
				&max77693_led_irq_chip,
				&max77693->irq_data_led);
	if (ret) {
		dev_err(max77693->dev, "failed to add irq chip: %d\n", ret);
		goto err_regmap;
	}

	ret = regmap_add_irq_chip(max77693->regmap, max77693->irq,
				IRQF_ONESHOT | IRQF_SHARED |
				IRQF_TRIGGER_FALLING, 0,
				&max77693_topsys_irq_chip,
				&max77693->irq_data_topsys);
	if (ret) {
		dev_err(max77693->dev, "failed to add irq chip: %d\n", ret);
		goto err_irq_topsys;
	}

	ret = regmap_add_irq_chip(max77693->regmap, max77693->irq,
				IRQF_ONESHOT | IRQF_SHARED |
				IRQF_TRIGGER_FALLING, 0,
				&max77693_charger_irq_chip,
				&max77693->irq_data_charger);
	if (ret) {
		dev_err(max77693->dev, "failed to add irq chip: %d\n", ret);
		goto err_irq_charger;
//.........这里部分代码省略.........
开发者ID:383530895,项目名称:linux,代码行数:101,代码来源:max77693.c


示例15: bcmpmu_i2c_probe

static int bcmpmu_i2c_probe(struct i2c_client *i2c,
			    const struct i2c_device_id *id)
{
	struct bcmpmu *bcmpmu;
	int ret = 0;
	struct bcmpmu_platform_data *pdata;
	struct i2c_client *clt;
	struct i2c_adapter *adp;
	struct bcmpmu_i2c *bcmpmu_i2c;

	pdata = (struct bcmpmu_platform_data *)i2c->dev.platform_data;
	if(pdata == NULL){
		printk(KERN_INFO "%s: invalid platform_data. \n", __func__);
		return -ENODEV;
	}

	printk(KERN_INFO "%s called\n", __func__);

	bcmpmu = kzalloc(sizeof(struct bcmpmu), GFP_KERNEL);
	if (bcmpmu == NULL) {
		printk(KERN_ERR "%s: failed to alloc mem.\n", __func__);
		kfree(i2c);
		ret = -ENOMEM;
		goto err;
	}

	bcmpmu_i2c = kzalloc(sizeof(struct bcmpmu_i2c), GFP_KERNEL);
	if (bcmpmu_i2c == NULL) {
		printk(KERN_ERR "%s: failed to alloc mem.\n", __func__);
		ret = -ENOMEM;
		goto err1;
	}

	i2c_set_clientdata(i2c, bcmpmu);
	bcmpmu->dev = &i2c->dev;
	bcmpmu_i2c->i2c_client = i2c;

	adp = i2c_get_adapter(pdata->i2c_adapter_id);
	clt = i2c_new_dummy(adp, pdata->i2c_board_info_map1->addr);
	if (!clt) {
		printk(KERN_ERR "%s: add new device for map1 failed\n", __func__);
		ret = -ENOMEM;
		goto err2;
	}

	clt->dev.platform_data = pdata;
	bcmpmu_i2c->i2c_client1 = clt;
	mutex_init(&bcmpmu_i2c->i2c_mutex);
#ifdef CONFIG_HAS_WAKELOCK
	wake_lock_init(&bcmpmu_i2c->i2c_lock, WAKE_LOCK_SUSPEND,
		"bcmpmu_i2c");
	bcmpmu_i2c->ref_count = 0;
#endif

#if defined(CONFIG_MFD_BCM_PWRMGR_SW_SEQUENCER)
	bcmpmu->read_dev = bcmpmu_i2c_pwrmgr_read;
	bcmpmu->write_dev = bcmpmu_i2c_pwrmgr_write;
	bcmpmu->read_dev_drct = bcmpmu_i2c_pwrmgr_read_direct;
	bcmpmu->write_dev_drct = bcmpmu_i2c_pwrmgr_write_direct;
	bcmpmu->read_dev_bulk = bcmpmu_i2c_pwrmgr_read_direct_bulk;
	bcmpmu->write_dev_bulk = bcmpmu_i2c_pwrmgr_write_direct_bulk;
	pr_info("%s:PWRMGR I2C Sequencer\n", __func__);
#else
	bcmpmu->read_dev = bcmpmu_i2c_read_device;
	bcmpmu->write_dev = bcmpmu_i2c_write_device;
	bcmpmu->read_dev_drct = bcmpmu_i2c_read_device_direct;
	bcmpmu->write_dev_drct = bcmpmu_i2c_write_device_direct;
	bcmpmu->read_dev_bulk = bcmpmu_i2c_read_device_direct_bulk;
	bcmpmu->write_dev_bulk = bcmpmu_i2c_write_device_direct_bulk;
#endif
	bcmpmu->pdata = pdata;
	bcmpmu_i2c->pagesize = pdata->i2c_pagesize;

	bcmpmu->accinfo = bcmpmu_i2c;

	bcmpmu_core_device.dev.platform_data = bcmpmu;
	platform_device_register(&bcmpmu_core_device);

	return ret;

err2:
	kfree(bcmpmu_i2c);
err1:
	kfree(bcmpmu);
err:
	return ret;
}
开发者ID:emreharbutoglu,项目名称:i9105Sammy,代码行数:87,代码来源:bcmpmu-i2c.c


示例16: palmas_i2c_probe

static int palmas_i2c_probe(struct i2c_client *i2c,
			    const struct i2c_device_id *id)
{
	struct palmas *palmas;
	struct palmas_platform_data *pdata;
	struct device_node *node = i2c->dev.of_node;
	int ret = 0, i;
	unsigned int reg, addr;
	int slave;
	struct mfd_cell *children;

	pdata = dev_get_platdata(&i2c->dev);

	if (node && !pdata) {
		pdata = devm_kzalloc(&i2c->dev, sizeof(*pdata), GFP_KERNEL);

		if (!pdata)
			return -ENOMEM;

		palmas_dt_to_pdata(node, pdata);
	}

	if (!pdata)
		return -EINVAL;

	palmas = devm_kzalloc(&i2c->dev, sizeof(struct palmas), GFP_KERNEL);
	if (palmas == NULL)
		return -ENOMEM;

	i2c_set_clientdata(i2c, palmas);
	palmas->dev = &i2c->dev;
	palmas->id = id->driver_data;
	palmas->irq = i2c->irq;

	for (i = 0; i < PALMAS_NUM_CLIENTS; i++) {
		if (i == 0)
			palmas->i2c_clients[i] = i2c;
		else {
			palmas->i2c_clients[i] =
					i2c_new_dummy(i2c->adapter,
							i2c->addr + i);
			if (!palmas->i2c_clients[i]) {
				dev_err(palmas->dev,
					"can't attach client %d\n", i);
				ret = -ENOMEM;
				goto err;
			}
		}
		palmas->regmap[i] = devm_regmap_init_i2c(palmas->i2c_clients[i],
				&palmas_regmap_config[i]);
		if (IS_ERR(palmas->regmap[i])) {
			ret = PTR_ERR(palmas->regmap[i]);
			dev_err(palmas->dev,
				"Failed to allocate regmap %d, err: %d\n",
				i, ret);
			goto err;
		}
	}

	/* Change IRQ into clear on read mode for efficiency */
	slave = PALMAS_BASE_TO_SLAVE(PALMAS_INTERRUPT_BASE);
	addr = PALMAS_BASE_TO_REG(PALMAS_INTERRUPT_BASE, PALMAS_INT_CTRL);
	reg = PALMAS_INT_CTRL_INT_CLEAR;

	regmap_write(palmas->regmap[slave], addr, reg);

	ret = regmap_add_irq_chip(palmas->regmap[slave], palmas->irq,
			IRQF_ONESHOT | IRQF_TRIGGER_LOW, 0, &palmas_irq_chip,
			&palmas->irq_data);
	if (ret < 0)
		goto err;

	slave = PALMAS_BASE_TO_SLAVE(PALMAS_PU_PD_OD_BASE);
	addr = PALMAS_BASE_TO_REG(PALMAS_PU_PD_OD_BASE,
			PALMAS_PRIMARY_SECONDARY_PAD1);

	if (pdata->mux_from_pdata) {
		reg = pdata->pad1;
		ret = regmap_write(palmas->regmap[slave], addr, reg);
		if (ret)
			goto err_irq;
	} else {
		ret = regmap_read(palmas->regmap[slave], addr, &reg);
		if (ret)
			goto err_irq;
	}

	if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_0))
		palmas->gpio_muxed |= PALMAS_GPIO_0_MUXED;
	if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK))
		palmas->gpio_muxed |= PALMAS_GPIO_1_MUXED;
	else if ((reg & PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK) ==
			(2 << PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT))
		palmas->led_muxed |= PALMAS_LED1_MUXED;
	else if ((reg & PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_MASK) ==
			(3 << PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_1_SHIFT))
		palmas->pwm_muxed |= PALMAS_PWM1_MUXED;
	if (!(reg & PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_2_MASK))
		palmas->gpio_muxed |= PALMAS_GPIO_2_MUXED;
	else if ((reg & PALMAS_PRIMARY_SECONDARY_PAD1_GPIO_2_MASK) ==
//.........这里部分代码省略.........
开发者ID:AiWinters,项目名称:linux,代码行数:101,代码来源:palmas.c


示例17: marimba_probe

static int marimba_probe(struct i2c_client *client,
				const struct i2c_device_id *id)
{
	struct marimba_platform_data *pdata = client->dev.platform_data;
	struct i2c_adapter *ssbi_adap;
	struct marimba *marimba;
	int i, status;

	if (!pdata) {
		dev_dbg(&client->dev, "no platform data?\n");
		return -EINVAL;
	}

	if (i2c_check_functionality(client->adapter, I2C_FUNC_I2C) == 0) {
		dev_dbg(&client->dev, "can't talk I2C?\n");
		return -EIO;
	}

	if (inuse) {
		dev_dbg(&client->dev, "driver already in use\n");
		return -EBUSY;
	}

	for (i = 0; i <= NUM_ADD; i++) {
		marimba = &marimba_modules[i];

		if (i == 0)
			marimba->client = client;
		else {
			if (i != MARIMBA_ID_TSADC)
				marimba->client = i2c_new_dummy(client->adapter,
							pdata->slave_id[i]);
			else {
				ssbi_adap = i2c_get_adapter(MARIMBA_SSBI_ADAP);
				marimba->client = i2c_new_dummy(ssbi_adap,
							pdata->slave_id[i]);
			}

			if (!marimba->client) {
				dev_err(&marimba->client->dev,
					"can't attach client %d\n", i);
				status = -ENOMEM;
				goto fail;
			}
			strlcpy(marimba->client->name, id->name,
						sizeof(marimba->client->name));
		}

		mutex_init(&marimba->xfer_lock);
	}

	inuse = true;

	if (pdata->marimba_setup != NULL)
		pdata->marimba_setup();

	marimba_init_reg(client);

	status = marimba_add_child(pdata);

	return 0;

fail:
	return status;
}
开发者ID:mtuton,项目名称:linux_u82x0,代码行数:65,代码来源:marimba-core.c


示例18: s35390a_probe

static int s35390a_probe(struct i2c_client *client,
			 const struct i2c_device_id *id)
{
	int err;
	unsigned int i;
	struct s35390a *s35390a;
	struct rtc_time tm;
	char buf[1];

	if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
		err = -ENODEV;
		goto exit;
	}

	s35390a = kzalloc(sizeof(struct s35390a), GFP_KERNEL);
	if (!s35390a) {
		err = -ENOMEM;
		goto exit;
	}

	s35390a->client[0] = client;
	i2c_set_clientdata(client, s35390a);

	/* This chip uses multiple addresses, use dummy devices for them */
	for (i = 1; i < 8; ++i) {
		s35390a->client[i] = i2c_new_dummy(client->adapter,
					client->addr + i);
		if (!s35390a->client[i]) {
			dev_err(&client->dev, "Address %02x unavailable\n",
						client->addr + i);
			err = -EBUSY;
			goto exit_dummy;
		}
	}

	err = s35390a_reset(s35390a);
	if (err < 0) {
		dev_err(&client->dev, "error resetting chip\n");
		goto exit_dummy;
	}

	err = s35390a_disable_test_mode(s35390a);
	if (err < 0) {
		dev_err(&client->dev, "error disabling test mode\n");
		goto exit_dummy;
	}

	err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS1, buf, sizeof(buf));
	if (err < 0) {
		dev_err(&client->dev, "error checking 12/24 hour mode\n");
		goto exit_dummy;
	}
	if (buf[0] & S35390A_FLAG_24H)
		s35390a->twentyfourhour = 1;
	else
		s35390a->twentyfourhour = 0;

	if (s35390a_get_datetime(client, &tm) < 0)
		dev_warn(&client->dev, "clock needs to be set\n");

	INIT_WORK(&s35390a->work, s35390a_work);

	if (client->irq > 0) {
		err = request_irq(client->irq, s35390a_irq, IRQF_TRIGGER_LOW,
				client->name, client);
		if (err) {
			dev_err(&client->dev, "unable to request IRQ\n");
			goto exit_dummy;
		}
	}

	s35390a->rtc = rtc_device_register(s35390a_driver.driver.name,
				&client->dev, &s35390a_rtc_ops, THIS_MODULE);

	if (IS_ERR(s35390a->rtc)) {
		err = PTR_ERR(s35390a->rtc);
		goto exit_intr;
	}
	s35390a->rtc->irq_freq = 0;
	s35390a->rtc->max_user_freq = 16;
	return 0;

exit_intr:
	free_irq(client->irq, client);

exit_dummy:
	for (i = 1; i < 8; ++i)
		if (s35390a->client[i])
			i2c_unregister_device(s35390a->client[i]);
	kfree(s35390a);
	i2c_set_clientdata(client, NULL);

exit:
	return err;
}
开发者ID:Aircell,项目名称:asp-kernel,代码行数:95,代码来源:rtc-s35390a.c


示例19: max732x_probe

static int __devinit max732x_probe(struct i2c_client *client,
				   const struct i2c_device_id *id)
{
	struct max732x_platform_data *pdata;
	struct max732x_chip *chip;
	struct i2c_client *c;
	uint16_t addr_a, addr_b;
	int ret, nr_port;

	pdata = client->dev.platform_data;
	if (pdata == NULL) {
		dev_dbg(&client->dev, "no platform data\n");
		return -EINVAL;
	}

	chip = kzalloc(sizeof(struct max732x_chip), GFP_KERNEL);
	if (chip == NULL)
		return -ENOMEM;
	chip->client = client;

	nr_port = max732x_setup_gpio(chip, id, pdata->gpio_base);

	addr_a = (client->addr & 0x0f) | 0x60;
	addr_b = (client->addr & 0x0f) | 0x50;

	switch (client->addr & 0x70) {
	case 0x60:
		chip->client_group_a = client;
		if (nr_port > 8) {
			c = i2c_new_dummy(client->adapter, addr_b);
			chip->client_group_b = chip->client_dummy = c;
		}
		break;
	case 0x50:
		chip->client_group_b = client;
		if (nr_port > 8) {
			c = i2c_new_dummy(client->adapter, addr_a);
			chip->client_group_a = chip->client_dummy = c;
		}
		break;
	default:
		dev_err(&client->dev, "invalid I2C address specified %02x\n",
				client->addr);
		ret = -EINVAL;
		goto out_failed;
	}

	mutex_init(&chip->lock);

	max732x_readb(chip, is_group_a(chip, 0), &chip->reg_out[0]);
	if (nr_port > 8)
		max732x_readb(chip, is_group_a(chip, 8), &chip->reg_out[1]);

	ret = max732x_irq_setup(chip, id);
	if (ret)
		goto out_failed;

	ret = gpiochip_add(&chip->gpio_chip);
	if (ret)
		goto out_failed;

	if (pdata->setup) {
		ret = pdata->setup(client, chip->gpio_chip.base,
				chip->gpio_chip.ngpio, pdata->context);
		if (ret < 0)
			dev_warn(&client->dev, "setup failed, %d\n", ret);
	}

	i2c_set_clientdata(client, chip);
	return 0;

out_failed:
	max732x_irq_teardown(chip);
	kfree(chip);
	return ret;
}
开发者ID:12rafael,项目名称:jellytimekernel,代码行数:76,代码来源:max732x.c


示例20: adv7180_probe

static int adv7180_probe(struct i2c_client *client,
			 const struct i2c_device_id *id)
{
	struct adv7180_state *state;
	struct v4l2_subdev *sd;
	int ret;

	/* Check if the adapter supports the needed features */
	if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA))
		return -EIO;

	v4l_info(client, "chip found @ 0x%02x (%s)\n",
		 client->addr, client->adapter->name);

	state = devm_kzalloc(&client->dev, sizeof(*state), GFP_KERNEL);
	if (state == NULL)
		return -ENOMEM;

	state->client = client;
	state->field = V4L2_FIELD_INTERLACED;
	state->chip_info = (struct adv7180_chip_info *)id->driver_data;

	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2) {
		state->csi_client = i2c_new_dummy(client->adapter,
				ADV7180_DEFAULT_CSI_I2C_ADDR);
		if (!state->csi_client)
			return -ENOMEM;
	}

	if (state->chip_info->flags & ADV7180_FLAG_I2P) {
		state->vpp_client = i2c_new_dummy(client->adapter,
				ADV7180_DEFAULT_VPP_I2C_ADDR);
		if (!state->vpp_client) {
			ret = -ENOMEM;
			goto err_unregister_csi_client;
		}
	}

	state->irq = client->irq;
	mutex_init(&state->mutex);
	state->autodetect = true;
	if (state->chip_info->flags & ADV7180_FLAG_RESET_POWERED)
		state->powered = true;
	else
		state->powered = false;
	state->input = 0;
	sd = &state->sd;
	v4l2_i2c_subdev_init(sd, client, &adv7180_ops);
	sd->flags = V4L2_SUBDEV_FL_HAS_DEVNODE;

	ret = adv7180_init_controls(state);
	if (ret)
		goto err_unregister_vpp_client;

	state->pad.flags = MEDIA_PAD_FL_SOURCE;
	sd->entity.flags |= MEDIA_ENT_F_ATV_DECODER;
	ret = media_entity_pads_init(&sd->entity, 1, &state->pad);
	if (ret)
		goto err_free_ctrl;

	ret = init_device(state);
	if (ret)
		goto err_media_entity_cleanup;

	if (state->irq) {
		ret = request_threaded_irq(client->irq, NULL, adv7180_irq,
					   IRQF_ONESHOT | IRQF_TRIGGER_FALLING,
					   KBUILD_MODNAME, state);
		if (ret)
			goto err_media_entity_cleanup;
	}

	ret = v4l2_async_register_subdev(sd);
	if (ret)
		goto err_free_irq;

	return 0;

err_free_irq:
	if (state->irq > 0)
		free_irq(client->irq, state);
err_media_entity_cleanup:
	media_entity_cleanup(&sd->entity);
err_free_ctrl:
	adv7180_exit_controls(state);
err_unregister_vpp_client:
	if (state->chip_info->flags & ADV7180_FLAG_I2P)
		i2c_unregister_device(state->vpp_client);
err_unregister_csi_client:
	if (state->chip_info->flags & ADV7180_FLAG_MIPI_CSI2)
		i2c_unregister_device(state->csi_client);
	mutex_destroy(&state->mutex);
	return ret;
}
开发者ID:020gzh,项目名称:linux,代码行数:94,代码来源:adv7180.c



注:本文中的i2c_new_dummy函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ i2c_put_adapter函数代码示例发布时间:2022-05-30
下一篇:
C++ i2c_new_device函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap