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

C++ regulator_register函数代码示例

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

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



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

示例1: da9052_regulator_probe

static int __devinit da9052_regulator_probe(struct platform_device *pdev)
{
	struct da9052_regulator_priv *priv;
	struct da9052_regulator_platform_data *pdata =
				(pdev->dev.platform_data);
	struct da9052 *da9052 = dev_get_drvdata(pdev->dev.parent);
	struct regulator_init_data  *init_data;
	struct da9052_platform_data *da9052_pdata = da9052->dev->platform_data;
	int i, ret = 0;

	if ((da9052_pdata == NULL) ||
		(da9052_pdata->num_regulators > DA9052_MAX_REGULATORS) ||
		(da9052_pdata->num_regulators <= 0))
		return -EINVAL;

	priv = kzalloc(sizeof(*priv) + sizeof(priv->regulators[0]) *
			da9052_pdata->num_regulators, GFP_KERNEL);
	if (priv == NULL)
		return -ENOMEM;

	priv->da9052 = da9052;
	for (i = 0; i < da9052_pdata->num_regulators; i++) {

		init_data = &pdata->regulators[i];
		init_data->driver_data = da9052;
		priv->regulators[i] = regulator_register(
				&da9052_regulators[i].reg_desc,
				&pdev->dev, init_data,
				priv);
		if (IS_ERR(priv->regulators[i])) {
			ret = PTR_ERR(priv->regulators[i]);
			goto err;
		}
	}
	platform_set_drvdata(pdev, priv);
	return 0;
err:
	while (--i >= 0)
		regulator_unregister(priv->regulators[i]);
	kfree(priv);
	return ret;
}
开发者ID:YCsuperlife,项目名称:imx53_kernel,代码行数:42,代码来源:da9052-regulator.c


示例2: regulator_fixed_voltage_probe

static int regulator_fixed_voltage_probe(struct platform_device *pdev)
{
	struct fixed_voltage_config *config = pdev->dev.platform_data;
	struct fixed_voltage_data *drvdata;
	int ret;

	drvdata = kzalloc(sizeof(struct fixed_voltage_data), GFP_KERNEL);
	if (drvdata == NULL) {
		ret = -ENOMEM;
		goto err;
	}

	drvdata->desc.name = kstrdup(config->supply_name, GFP_KERNEL);
	if (drvdata->desc.name == NULL) {
		ret = -ENOMEM;
		goto err;
	}
	drvdata->desc.type = REGULATOR_VOLTAGE;
	drvdata->desc.owner = THIS_MODULE;
	drvdata->desc.ops = &fixed_voltage_ops,

	drvdata->microvolts = config->microvolts;

	drvdata->dev = regulator_register(&drvdata->desc, drvdata);
	if (IS_ERR(drvdata->dev)) {
		ret = PTR_ERR(drvdata->dev);
		goto err_name;
	}

	platform_set_drvdata(pdev, drvdata);

	dev_dbg(&pdev->dev, "%s supplying %duV\n", drvdata->desc.name,
		drvdata->microvolts);

	return 0;

err_name:
	kfree(drvdata->desc.name);
err:
	kfree(drvdata);
	return ret;
}
开发者ID:johnny,项目名称:CobraDroidBeta,代码行数:42,代码来源:fixed.c


示例3: pcf50633_regulator_probe

static int __devinit pcf50633_regulator_probe(struct platform_device *pdev)
{
	struct regulator_dev *rdev;
	struct pcf50633 *pcf;

	/* Already set by core driver */
	pcf = dev_to_pcf50633(pdev->dev.parent);

	rdev = regulator_register(&regulators[pdev->id], &pdev->dev,
				  pdev->dev.platform_data, pcf);
	if (IS_ERR(rdev))
		return PTR_ERR(rdev);

	platform_set_drvdata(pdev, rdev);

	if (pcf->pdata->regulator_registered)
		pcf->pdata->regulator_registered(pcf, pdev->id);

	return 0;
}
开发者ID:Medvedroid,项目名称:OT_903D-kernel-2.6.35.7,代码行数:20,代码来源:pcf50633-regulator.c


示例4: ad5398_probe

static int __devinit ad5398_probe(struct i2c_client *client,
				const struct i2c_device_id *id)
{
	struct regulator_dev *rdev;
	struct regulator_init_data *init_data = client->dev.platform_data;
	struct ad5398_chip_info *chip;
	const struct ad5398_current_data_format *df =
			(struct ad5398_current_data_format *)id->driver_data;
	int ret;

	if (!init_data)
		return -EINVAL;

	chip = kzalloc(sizeof(*chip), GFP_KERNEL);
	if (!chip)
		return -ENOMEM;

	chip->client = client;

	chip->min_uA = df->min_uA;
	chip->max_uA = df->max_uA;
	chip->current_level = 1 << df->current_bits;
	chip->current_offset = df->current_offset;
	chip->current_mask = (chip->current_level - 1) << chip->current_offset;

	rdev = regulator_register(&ad5398_reg, &client->dev, init_data, chip);
	if (IS_ERR(rdev)) {
		ret = PTR_ERR(rdev);
		dev_err(&client->dev, "failed to register %s %s\n",
			id->name, ad5398_reg.name);
		goto err;
	}

	i2c_set_clientdata(client, chip);
	dev_dbg(&client->dev, "%s regulator driver is registered.\n", id->name);
	return 0;

err:
	kfree(chip);
	return ret;
}
开发者ID:kvaneesh,项目名称:linux-kvm,代码行数:41,代码来源:ad5398.c


示例5: footswitch_probe

static int footswitch_probe(struct platform_device *pdev)
{
	struct footswitch *fs;
	struct regulator_init_data *init_data;
	int rc;

	if (pdev == NULL)
		return -EINVAL;

	if (pdev->id >= MAX_FS)
		return -ENODEV;

	init_data = pdev->dev.platform_data;
	fs = &footswitches[pdev->id];

	rc = set_rail_state(fs->pcom_id, PCOM_CLKCTL_RPC_RAIL_ENABLE);
	if (rc)
		return rc;
	rc = set_rail_mode(fs->pcom_id, PCOM_RAIL_MODE_MANUAL);
	if (rc)
		return rc;

	rc = get_clocks(&pdev->dev, fs);
	if (rc)
		return rc;

	fs->rdev = regulator_register(&fs->desc, &pdev->dev,
							init_data, fs, NULL);
	if (IS_ERR(fs->rdev)) {
		pr_err("regulator_register(%s) failed\n", fs->desc.name);
		rc = PTR_ERR(fs->rdev);
		goto err_register;
	}

	return 0;

err_register:
	put_clocks(fs);

	return rc;
}
开发者ID:Blackburn29,项目名称:PsycoKernel,代码行数:41,代码来源:footswitch-pcom.c


示例6: bq24022_probe

static int __init bq24022_probe(struct platform_device *pdev)
{
	struct bq24022_mach_info *pdata = pdev->dev.platform_data;
	struct regulator_dev *bq24022;
	int ret;

	if (!pdata || !pdata->gpio_nce || !pdata->gpio_iset2)
		return -EINVAL;

	ret = gpio_request(pdata->gpio_nce, "ncharge_en");
	if (ret) {
		dev_dbg(&pdev->dev, "couldn't request nCE GPIO: %d\n",
			pdata->gpio_nce);
		goto err_ce;
	}
	ret = gpio_request(pdata->gpio_iset2, "charge_mode");
	if (ret) {
		dev_dbg(&pdev->dev, "couldn't request ISET2 GPIO: %d\n",
			pdata->gpio_iset2);
		goto err_iset2;
	}
	ret = gpio_direction_output(pdata->gpio_iset2, 0);
	ret = gpio_direction_output(pdata->gpio_nce, 1);

	bq24022 = regulator_register(&bq24022_desc, &pdev->dev, pdata);
	if (IS_ERR(bq24022)) {
		dev_dbg(&pdev->dev, "couldn't register regulator\n");
		ret = PTR_ERR(bq24022);
		goto err_reg;
	}
	platform_set_drvdata(pdev, bq24022);
	dev_dbg(&pdev->dev, "registered regulator\n");

	return 0;
err_reg:
	gpio_free(pdata->gpio_iset2);
err_iset2:
	gpio_free(pdata->gpio_nce);
err_ce:
	return ret;
}
开发者ID:458941968,项目名称:mini2440-kernel-2.6.29,代码行数:41,代码来源:bq24022.c


示例7: devres_alloc

/**
 * devm_regulator_register - Resource managed regulator_register()
 * @regulator_desc: regulator to register
 * @config: runtime configuration for regulator
 *
 * Called by regulator drivers to register a regulator.  Returns a
 * valid pointer to struct regulator_dev on success or an ERR_PTR() on
 * error.  The regulator will automatically be released when the device
 * is unbound.
 */
struct regulator_dev *devm_regulator_register(struct device *dev,
				  const struct regulator_desc *regulator_desc,
				  const struct regulator_config *config)
{
	struct regulator_dev **ptr, *rdev;

	ptr = devres_alloc(devm_rdev_release, sizeof(*ptr),
			   GFP_KERNEL);
	if (!ptr)
		return ERR_PTR(-ENOMEM);

	rdev = regulator_register(regulator_desc, config);
	if (!IS_ERR(rdev)) {
		*ptr = rdev;
		devres_add(dev, ptr);
	} else {
		devres_free(ptr);
	}

	return rdev;
}
开发者ID:arend,项目名称:platform_hardware_broadcom_wlan,代码行数:31,代码来源:backport-3.13.c


示例8: lp8788_buck_probe

static int lp8788_buck_probe(struct platform_device *pdev)
{
    struct lp8788 *lp = dev_get_drvdata(pdev->dev.parent);
    int id = pdev->id;
    struct lp8788_buck *buck;
    struct regulator_config cfg = { };
    struct regulator_dev *rdev;
    int ret;

    if (id >= LP8788_NUM_BUCKS)
        return -EINVAL;

    buck = devm_kzalloc(&pdev->dev, sizeof(struct lp8788_buck), GFP_KERNEL);
    if (!buck)
        return -ENOMEM;

    buck->lp = lp;

    ret = lp8788_init_dvs(pdev, buck, id);
    if (ret)
        return ret;

    cfg.dev = pdev->dev.parent;
    cfg.init_data = lp->pdata ? lp->pdata->buck_data[id] : NULL;
    cfg.driver_data = buck;
    cfg.regmap = lp->regmap;

    rdev = regulator_register(&lp8788_buck_desc[id], &cfg);
    if (IS_ERR(rdev)) {
        ret = PTR_ERR(rdev);
        dev_err(&pdev->dev, "BUCK%d regulator register err = %d\n",
                id + 1, ret);
        return ret;
    }

    buck->regulator = rdev;
    platform_set_drvdata(pdev, buck);

    return 0;
}
开发者ID:jay-caoj,项目名称:linux-3.9.6,代码行数:40,代码来源:lp8788-buck.c


示例9: smb349_regulator_init

static int smb349_regulator_init(struct smb349_charger *chip)
{
	int rc = 0;
	struct regulator_init_data *init_data;
	struct regulator_config cfg = {};

	init_data = of_get_regulator_init_data(chip->dev, chip->dev->of_node);
	if (!init_data) {
		dev_err(chip->dev, "Unable to allocate memory\n");
		return -ENOMEM;
	}

	if (init_data->constraints.name) {
		chip->otg_vreg.rdesc.owner = THIS_MODULE;
		chip->otg_vreg.rdesc.type = REGULATOR_VOLTAGE;
		chip->otg_vreg.rdesc.ops = &smb349_chg_otg_reg_ops;
		chip->otg_vreg.rdesc.name = init_data->constraints.name;

		cfg.dev = chip->dev;
		cfg.init_data = init_data;
		cfg.driver_data = chip;
		cfg.of_node = chip->dev->of_node;

		init_data->constraints.valid_ops_mask
			|= REGULATOR_CHANGE_STATUS;

		chip->otg_vreg.rdev = regulator_register(
						&chip->otg_vreg.rdesc, &cfg);
		if (IS_ERR(chip->otg_vreg.rdev)) {
			rc = PTR_ERR(chip->otg_vreg.rdev);
			chip->otg_vreg.rdev = NULL;
			if (rc != -EPROBE_DEFER)
				dev_err(chip->dev,
					"OTG reg failed, rc=%d\n", rc);
		}
	}

	return rc;
}
开发者ID:Menpiko,项目名称:SnaPKernel-N6P,代码行数:39,代码来源:smb349-charger.c


示例10: pm822_regulator_probe

static int __devinit pm822_regulator_probe(struct platform_device *pdev)
{
	struct pm822_chip *chip = dev_get_drvdata(pdev->dev.parent);
	struct pm822_regulator_info *info = NULL;
	struct regulator_init_data *pdata = pdev->dev.platform_data;
	struct resource *res;
	int i;

	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
	if (res == NULL) {
		dev_err(&pdev->dev, "No I/O resource!\n");
		return -EINVAL;
	}

	for (i = 0; i < ARRAY_SIZE(pm822_regulator_info); i++) {
		info = &pm822_regulator_info[i];
		if (info->desc.id == res->start)
			break;
	}
	if ((i < 0) || (i > PM822_ID_RG_MAX)) {
		dev_err(&pdev->dev, "Failed to find regulator %d\n",
			res->start);
		return -EINVAL;
	}

	info->map = chip->subchip->regmap_power;
	info->chip = chip;
	info->regulator = regulator_register(&info->desc, &pdev->dev,
					     pdata, info, NULL);
	if (IS_ERR(info->regulator)) {
		dev_err(&pdev->dev, "failed to register regulator %s\n",
			info->desc.name);
		return PTR_ERR(info->regulator);
	}

	platform_set_drvdata(pdev, info);
	return 0;
}
开发者ID:maxfu,项目名称:android_kernel_armada_pxa1088,代码行数:38,代码来源:88pm822.c


示例11: db8500_regulator_register

static int db8500_regulator_register(struct platform_device *pdev,
					struct regulator_init_data *init_data,
					int id,
					struct device_node *np)
{
	struct dbx500_regulator_info *info;
	struct regulator_config config = { };
	int err;

	/* assign per-regulator data */
	info = &dbx500_regulator_info[id];
	info->dev = &pdev->dev;

	config.dev = &pdev->dev;
	config.init_data = init_data;
	config.driver_data = info;
	config.of_node = np;

	/* register with the regulator framework */
	info->rdev = regulator_register(&info->desc, &config);
	if (IS_ERR(info->rdev)) {
		err = PTR_ERR(info->rdev);
		dev_err(&pdev->dev, "failed to register %s: err %i\n",
			info->desc.name, err);

		/* if failing, unregister all earlier regulators */
		while (--id >= 0) {
			info = &dbx500_regulator_info[id];
			regulator_unregister(info->rdev);
		}
		return err;
	}

	dev_dbg(rdev_get_dev(info->rdev),
		"regulator-%s-probed\n", info->desc.name);

	return 0;
}
开发者ID:AdrianHuang,项目名称:linux-3.8.13,代码行数:38,代码来源:db8500-prcmu.c


示例12: db8500_regulator_probe

static int __devinit db8500_regulator_probe(struct platform_device *pdev)
{
	struct regulator_init_data *db8500_init_data =
					dev_get_platdata(&pdev->dev);
	int i, err;

	/* register all regulators */
	for (i = 0; i < ARRAY_SIZE(db8500_regulator_info); i++) {
		struct db8500_regulator_info *info;
		struct regulator_init_data *init_data = &db8500_init_data[i];

		/* assign per-regulator data */
		info = &db8500_regulator_info[i];
		info->dev = &pdev->dev;

		/* register with the regulator framework */
		info->rdev = regulator_register(&info->desc, &pdev->dev,
				init_data, info);
		if (IS_ERR(info->rdev)) {
			err = PTR_ERR(info->rdev);
			dev_err(&pdev->dev, "failed to register %s: err %i\n",
				info->desc.name, err);

			/* if failing, unregister all earlier regulators */
			while (--i >= 0) {
				info = &db8500_regulator_info[i];
				regulator_unregister(info->rdev);
			}
			return err;
		}

		dev_dbg(rdev_get_dev(info->rdev),
			"regulator-%s-probed\n", info->desc.name);
	}

	return 0;
}
开发者ID:badwtg1111,项目名称:linux-2.6,代码行数:37,代码来源:db8500-prcmu.c


示例13: footswitch_probe

static int footswitch_probe(struct platform_device *pdev)
{
	struct footswitch *fs;
	struct regulator_init_data *init_data;
	int rc;

	if (pdev == NULL)
		return -EINVAL;

	if (pdev->id >= MAX_FS)
		return -ENODEV;

	fs = &footswitches[pdev->id];
	if (!fs->is_manual) {
		pr_err("%s is not in manual mode\n", fs->desc.name);
		return -EINVAL;
	}
	init_data = pdev->dev.platform_data;

	rc = get_clocks(&pdev->dev, fs);
	if (rc)
		return rc;

	fs->rdev = regulator_register(&fs->desc, &pdev->dev, init_data, fs);
	if (IS_ERR(fs->rdev)) {
		pr_err("regulator_register(%s) failed\n", fs->desc.name);
		rc = PTR_ERR(fs->rdev);
		goto err_register;
	}

	return 0;

err_register:
	put_clocks(fs);

	return rc;
}
开发者ID:KarenArzumanyan,项目名称:android_kernel_leo_3.0.16,代码行数:37,代码来源:footswitch-pcom.c


示例14: tps65217_regulator_probe

static int __devinit tps65217_regulator_probe(struct platform_device *pdev)
{
	struct regulator_dev *rdev;
	struct tps65217 *tps;
	struct tps_info *info = &tps65217_pmic_regs[pdev->id];
	struct regulator_config config = { };

	/* Already set by core driver */
	tps = dev_to_tps65217(pdev->dev.parent);
	tps->info[pdev->id] = info;

	config.dev = &pdev->dev;
	config.of_node = pdev->dev.of_node;
	config.init_data = pdev->dev.platform_data;
	config.driver_data = tps;

	rdev = regulator_register(&regulators[pdev->id], &config);
	if (IS_ERR(rdev))
		return PTR_ERR(rdev);

	platform_set_drvdata(pdev, rdev);

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


示例15: axp_regulator_probe

static int __devinit axp_regulator_probe(struct platform_device *pdev)
{
	struct axp_regulator_info *ri = NULL;
	struct regulator_dev *rdev;
	

	ri = find_regulator_info(pdev->id);
	if (ri == NULL) {
		dev_err(&pdev->dev, "invalid regulator ID specified\n");
		return -EINVAL;
	}

	if (ri->desc.id == AXP_ID_LDO1 || ri->desc.id == AXP_ID_LDO2 \
		|| ri->desc.id == AXP_ID_LDO3 || ri->desc.id == AXP_ID_BUCK1 \
		|| ri->desc.id == AXP_ID_BUCK2 ||ri->desc.id == AXP_ID_BUCK3)
		ri->desc.ops = &axp_ops;
	
	if(ri->desc.id == AXP_ID_LDO4)
		ri->desc.ops = &axp_ldo4_ops;


	if(ri->desc.id == AXP_ID_LDOIO0)
		ri->desc.ops = &axp_ldoio0_ops;


	rdev = regulator_register(&ri->desc, &pdev->dev,
				  pdev->dev.platform_data, ri);
	if (IS_ERR(rdev)) {
		dev_err(&pdev->dev, "failed to register regulator %s\n",
				ri->desc.name);
		return PTR_ERR(rdev);
	}
	platform_set_drvdata(pdev, rdev);
	
	return 0;
}
开发者ID:Galland,项目名称:picuntu-3.0.8-alok,代码行数:36,代码来源:axp-regu.c


示例16: pm8058_xo_buffer_probe

static int __devinit pm8058_xo_buffer_probe(struct platform_device *pdev)
{
	struct regulator_desc *rdesc;
	struct pm8058_xo_buffer *xo;
	int rc = 0;

	if (pdev == NULL)
		return -EINVAL;

	if (pdev->id >= 0 && pdev->id < PM8058_XO_ID_MAX) {
		rdesc = &pm8058_xo_buffer_desc[pdev->id];
		xo = &pm8058_xo_buffer[pdev->id];
		xo->pdata = pdev->dev.platform_data;
		xo->dev  = &pdev->dev;

		rc = pm8058_init_xo_buffer(xo);
		if (rc)
			goto bail;

		xo->rdev = regulator_register(rdesc, &pdev->dev,
					&xo->pdata->init_data, xo);
		if (IS_ERR(xo->rdev)) {
			rc = PTR_ERR(xo->rdev);
			pr_err("FAIL: regulator_register(%s): rc=%d\n",
				pm8058_xo_buffer_desc[pdev->id].name, rc);
		}
	} else {
		rc = -ENODEV;
	}

bail:
	if (rc)
		pr_err("Error: xo-id=%d, rc=%d\n", pdev->id, rc);

	return rc;
}
开发者ID:Amin-jkr,项目名称:android_kernel_semc_msm8660-1,代码行数:36,代码来源:pm8058-xo.c


示例17: axp_regulator_probe

static int __devinit axp_regulator_probe(struct platform_device *pdev)
{
	struct regulator_dev *rdev;
	struct  axp_reg_init * platform_data = (struct  axp_reg_init *)(pdev->dev.platform_data);
	struct axp_regulator_info *info = platform_data->info;
	int ret;

	rdev = regulator_register(&info->desc, &pdev->dev, &(platform_data->axp_reg_init_data), info, NULL);
	if (IS_ERR(rdev)) {
		dev_err(&pdev->dev, "failed to register regulator %s\n",
				info->desc.name);
		return PTR_ERR(rdev);
	}
	platform_set_drvdata(pdev, rdev);

	if(info->desc.id == AXP20_ID_DCDC2 ||info->desc.id == AXP20_ID_DCDC3){
		ret = axp_regu_create_attrs(pdev);
		if(ret){
			return ret;
		}
	}

	return 0;
}
开发者ID:GREYFOXRGR,项目名称:BPI-M3-bsp,代码行数:24,代码来源:axp20-regu.c


示例18: s2mps13_pmic_probe

static int s2mps13_pmic_probe(struct platform_device *pdev)
{
	struct sec_pmic_dev *iodev = dev_get_drvdata(pdev->dev.parent);
	struct sec_platform_data *pdata = iodev->pdata;
	struct regulator_config config = { };
	struct s2mps13_info *s2mps13;
	int i, ret;
	unsigned int s2mps13_desc_type;

	ret = sec_reg_read(iodev, S2MPS13_REG_ID, &iodev->rev_num);
	if (ret < 0)
		return ret;
	s2mps13_desc_type = SEC_PMIC_REV(iodev) ? S2MPS13_DESC_TYPE1 : S2MPS13_DESC_TYPE0;

	if (iodev->dev->of_node) {
		ret = s2mps13_pmic_dt_parse_pdata(iodev, pdata);
		if (ret)
			return ret;
	}

	if (!pdata) {
		dev_err(pdev->dev.parent, "Platform data not supplied\n");
		return -ENODEV;
	}

	s2mps13 = devm_kzalloc(&pdev->dev, sizeof(struct s2mps13_info),
				GFP_KERNEL);
	if (!s2mps13)
		return -ENOMEM;

	s2mps13->dvs_en = pdata->dvs_en;
	s2mps13->g3d_en = pdata->g3d_en;
	s2mps13->iodev = iodev;
	static_info = s2mps13;

	if (SEC_PMIC_REV(iodev) > 0x02 && gpio_is_valid(pdata->dvs_pin)) {
		if (!pdata->dvs_en) {
			/* Off DVS Control GPIO */
			ret = devm_gpio_request(&pdev->dev, pdata->dvs_pin,
						"S2MPS13 DVS_PIN");
			if (ret < 0)
				return ret;
			gpio_direction_output(pdata->dvs_pin, 0);
		} else {
			/* Set DVS Regulator Voltage */
			ret = sec_reg_write(iodev, S2MPS13_REG_B6CTRL3, 0x28);
			if (ret < 0)
				return ret;

			if (!gpio_is_valid(pdata->dvs_pin)) {
				dev_err(&pdev->dev, "dvs_pin GPIO NOT VALID\n");
				return -EINVAL;
			}
		}
		s2mps13->dvs_pin = pdata->dvs_pin;
	}

	platform_set_drvdata(pdev, s2mps13);

	for (i = 0; i < pdata->num_regulators; i++) {
		int id = pdata->regulators[i].id;
		config.dev = &pdev->dev;
		config.regmap = iodev->regmap;
		config.init_data = pdata->regulators[i].initdata;
		config.driver_data = s2mps13;
		config.of_node = pdata->regulators[i].reg_node;
		s2mps13->opmode[id] = regulators[s2mps13_desc_type][id].enable_mask;

		s2mps13->rdev[i] = regulator_register(
					&regulators[s2mps13_desc_type][id], &config);
		if (IS_ERR(s2mps13->rdev[i])) {
			ret = PTR_ERR(s2mps13->rdev[i]);
			dev_err(&pdev->dev, "regulator init failed for %d\n",
				i);
			s2mps13->rdev[i] = NULL;
			goto err;
		}
	}
	if (pdata->g3d_en
		&& SEC_PMIC_REV(iodev) > 0x02 && gpio_is_valid(pdata->g3d_pin)) {
		ret = devm_gpio_request(&pdev->dev, pdata->g3d_pin,
					"S2MPS13 G3D_PIN");
		if (pdata->g3d_en) {
			gpio_direction_output(pdata->g3d_pin, 1);
			udelay(128);
			ret = sec_reg_update(iodev, S2MPS13_REG_B6CTRL1, 0x00, 0xC0);
			ret = sec_reg_update(iodev, S2MPS13_REG_LDO_DVS3, 0x02, 0x02);
		} else
			gpio_direction_output(pdata->g3d_pin, 0);

		s2mps13->g3d_pin = pdata->g3d_pin;
	}
	/* PMIC AVP(Adaptive Voltage Positioning) Configuration */
	if (pdata->ap_buck_avp_en) {
		sec_reg_write(iodev, 0x91, 0x4F);  /* Buck4 AVP level 11mV/A */
		sec_reg_write(iodev, 0x99, 0x4D);  /* Buck6 AVP level 7mV/A */
		sec_reg_update(iodev, S2MPS13_REG_B4CTRL1, 0x02, 0x02);  /* Buck4 AVP On */
		sec_reg_update(iodev, S2MPS13_REG_B6CTRL1, 0x02, 0x02);  /* Buck6 AVP On */
	}
	if (pdata->sub_buck_avp_en) {
//.........这里部分代码省略.........
开发者ID:khaliullov,项目名称:kernel_g850,代码行数:101,代码来源:s2mps13.c


示例19: regulator_stub_probe

static int regulator_stub_probe(struct platform_device *pdev)
{
	struct regulator_config reg_config = {};
	struct regulator_init_data *init_data = NULL;
	struct device *dev = &pdev->dev;
	struct stub_regulator_pdata *vreg_pdata;
	struct regulator_desc *rdesc;
	struct regulator_stub *vreg_priv;
	int rc;

	vreg_priv = kzalloc(sizeof(*vreg_priv), GFP_KERNEL);
	if (!vreg_priv) {
		dev_err(dev, "%s: Unable to allocate memory\n",
				__func__);
		return -ENOMEM;
	}

	if (dev->of_node) {
		/* Use device tree. */
		init_data = of_get_regulator_init_data(dev,
						       dev->of_node);
		if (!init_data) {
			dev_err(dev, "%s: unable to allocate memory\n",
					__func__);
			rc = -ENOMEM;
			goto err_probe;
		}

		if (init_data->constraints.name == NULL) {
			dev_err(dev, "%s: regulator name not specified\n",
				__func__);
			rc = -EINVAL;
			goto err_probe;
		}

		if (of_get_property(dev->of_node, "parent-supply", NULL))
			init_data->supply_regulator = "parent";

		of_property_read_u32(dev->of_node, "qcom,system-load",
					&vreg_priv->system_uA);
		of_property_read_u32(dev->of_node, "qcom,hpm-min-load",
					&vreg_priv->hpm_min_load);

		init_data->constraints.input_uV	= init_data->constraints.max_uV;

		init_data->constraints.valid_ops_mask
			|= REGULATOR_CHANGE_STATUS;
		init_data->constraints.valid_ops_mask
			|= REGULATOR_CHANGE_VOLTAGE;
		init_data->constraints.valid_ops_mask
			|= REGULATOR_CHANGE_MODE | REGULATOR_CHANGE_DRMS;
		init_data->constraints.valid_modes_mask
			= REGULATOR_MODE_NORMAL | REGULATOR_MODE_IDLE;
	} else {
		/* Use platform data. */
		vreg_pdata = dev->platform_data;
		if (!vreg_pdata) {
			dev_err(dev, "%s: no platform data\n", __func__);
			rc = -EINVAL;
			goto err_probe;
		}
		init_data = &vreg_pdata->init_data;

		vreg_priv->system_uA = vreg_pdata->system_uA;
		vreg_priv->hpm_min_load = vreg_pdata->hpm_min_load;
	}

	dev_set_drvdata(dev, vreg_priv);

	rdesc = &vreg_priv->rdesc;
	strlcpy(vreg_priv->name, init_data->constraints.name,
						   STUB_REGULATOR_MAX_NAME);
	rdesc->name = vreg_priv->name;
	rdesc->ops = &regulator_stub_ops;

	/*
	 * Ensure that voltage set points are handled correctly for regulators
	 * which have a specified voltage constraint range, as well as those
	 * that do not.
	 */
	if (init_data->constraints.min_uV == 0 &&
	    init_data->constraints.max_uV == 0)
		rdesc->n_voltages = 0;
	else
		rdesc->n_voltages = 2;

	rdesc->id    = pdev->id;
	rdesc->owner = THIS_MODULE;
	rdesc->type  = REGULATOR_VOLTAGE;
	vreg_priv->voltage = init_data->constraints.min_uV;
	if (vreg_priv->system_uA >= vreg_priv->hpm_min_load)
		vreg_priv->mode = REGULATOR_MODE_NORMAL;
	else
		vreg_priv->mode = REGULATOR_MODE_IDLE;

	reg_config.dev = dev;
	reg_config.init_data = init_data;
	reg_config.driver_data = vreg_priv;
	reg_config.of_node = dev->of_node;
	vreg_priv->rdev = regulator_register(rdesc, &reg_config);
//.........这里部分代码省略.........
开发者ID:AD5GB,项目名称:kernel_n5_3.10-experimental,代码行数:101,代码来源:stub-regulator.c


示例20: anatop_regulator_probe

static int __devinit anatop_regulator_probe(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct device_node *np = dev->of_node;
	struct regulator_desc *rdesc;
	struct regulator_dev *rdev;
	struct anatop_regulator *sreg;
	struct regulator_init_data *initdata;
	struct anatop *anatopmfd = dev_get_drvdata(pdev->dev.parent);
	int ret = 0;

	initdata = of_get_regulator_init_data(dev, np);
	sreg = devm_kzalloc(dev, sizeof(*sreg), GFP_KERNEL);
	if (!sreg)
		return -ENOMEM;
	sreg->initdata = initdata;
	sreg->name = kstrdup(of_get_property(np, "regulator-name", NULL),
			     GFP_KERNEL);
	rdesc = &sreg->rdesc;
	memset(rdesc, 0, sizeof(*rdesc));
	rdesc->name = sreg->name;
	rdesc->ops = &anatop_rops;
	rdesc->type = REGULATOR_VOLTAGE;
	rdesc->owner = THIS_MODULE;
	sreg->mfd = anatopmfd;
	ret = of_property_read_u32(np, "anatop-reg-offset",
				   &sreg->control_reg);
	if (ret) {
		dev_err(dev, "no anatop-reg-offset property set\n");
		goto anatop_probe_end;
	}
	ret = of_property_read_u32(np, "anatop-vol-bit-width",
				   &sreg->vol_bit_width);
	if (ret) {
		dev_err(dev, "no anatop-vol-bit-width property set\n");
		goto anatop_probe_end;
	}
	ret = of_property_read_u32(np, "anatop-vol-bit-shift",
				   &sreg->vol_bit_shift);
	if (ret) {
		dev_err(dev, "no anatop-vol-bit-shift property set\n");
		goto anatop_probe_end;
	}
	ret = of_property_read_u32(np, "anatop-min-bit-val",
				   &sreg->min_bit_val);
	if (ret) {
		dev_err(dev, "no anatop-min-bit-val property set\n");
		goto anatop_probe_end;
	}
	ret = of_property_read_u32(np, "anatop-min-voltage",
				   &sreg->min_voltage);
	if (ret) {
		dev_err(dev, "no anatop-min-voltage property set\n");
		goto anatop_probe_end;
	}
	ret = of_property_read_u32(np, "anatop-max-voltage",
				   &sreg->max_voltage);
	if (ret) {
		dev_err(dev, "no anatop-max-voltage property set\n");
		goto anatop_probe_end;
	}

	rdesc->n_voltages = (sreg->max_voltage - sreg->min_voltage)
		/ 25000 + 1;

	
	rdev = regulator_register(rdesc, dev,
				  initdata, sreg, pdev->dev.of_node);
	if (IS_ERR(rdev)) {
		dev_err(dev, "failed to register %s\n",
			rdesc->name);
		ret = PTR_ERR(rdev);
		goto anatop_probe_end;
	}

	platform_set_drvdata(pdev, rdev);

anatop_probe_end:
	if (ret)
		kfree(sreg->name);

	return ret;
}
开发者ID:DirtyDroidX,项目名称:android_kernel_htc_m8ul,代码行数:83,代码来源:anatop-regulator.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ regulator_set_optimum_mode函数代码示例发布时间:2022-05-30
下一篇:
C++ regulator_put函数代码示例发布时间: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