Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4faa54e5 authored by Mark Brown's avatar Mark Brown
Browse files

Merge remote-tracking branches 'regulator/topic/max1586',...

Merge remote-tracking branches 'regulator/topic/max1586', 'regulator/topic/max77686', 'regulator/topic/max77693', 'regulator/topic/max8649', 'regulator/topic/max8660', 'regulator/topic/max8907', 'regulator/topic/max8925' and 'regulator/topic/max8952' into regulator-next
Loading
+6 −9
Original line number Original line Diff line number Diff line
@@ -46,8 +46,6 @@ struct max1586_data {


	unsigned int v3_curr_sel;
	unsigned int v3_curr_sel;
	unsigned int v6_curr_sel;
	unsigned int v6_curr_sel;

	struct regulator_dev *rdev[0];
};
};


/*
/*
@@ -162,14 +160,12 @@ static struct regulator_desc max1586_reg[] = {
static int max1586_pmic_probe(struct i2c_client *client,
static int max1586_pmic_probe(struct i2c_client *client,
					const struct i2c_device_id *i2c_id)
					const struct i2c_device_id *i2c_id)
{
{
	struct regulator_dev **rdev;
	struct max1586_platform_data *pdata = dev_get_platdata(&client->dev);
	struct max1586_platform_data *pdata = dev_get_platdata(&client->dev);
	struct regulator_config config = { };
	struct regulator_config config = { };
	struct max1586_data *max1586;
	struct max1586_data *max1586;
	int i, id;
	int i, id;


	max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data) +
	max1586 = devm_kzalloc(&client->dev, sizeof(struct max1586_data),
			sizeof(struct regulator_dev *) * (MAX1586_V6 + 1),
			GFP_KERNEL);
			GFP_KERNEL);
	if (!max1586)
	if (!max1586)
		return -ENOMEM;
		return -ENOMEM;
@@ -186,8 +182,9 @@ static int max1586_pmic_probe(struct i2c_client *client,
	max1586->v3_curr_sel = 24; /* 1.3V */
	max1586->v3_curr_sel = 24; /* 1.3V */
	max1586->v6_curr_sel = 0;
	max1586->v6_curr_sel = 0;


	rdev = max1586->rdev;
	for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) {
	for (i = 0; i < pdata->num_subdevs && i <= MAX1586_V6; i++) {
		struct regulator_dev *rdev;

		id = pdata->subdevs[i].id;
		id = pdata->subdevs[i].id;
		if (!pdata->subdevs[i].platform_data)
		if (!pdata->subdevs[i].platform_data)
			continue;
			continue;
@@ -207,12 +204,12 @@ static int max1586_pmic_probe(struct i2c_client *client,
		config.init_data = pdata->subdevs[i].platform_data;
		config.init_data = pdata->subdevs[i].platform_data;
		config.driver_data = max1586;
		config.driver_data = max1586;


		rdev[i] = devm_regulator_register(&client->dev,
		rdev = devm_regulator_register(&client->dev,
						  &max1586_reg[id], &config);
						  &max1586_reg[id], &config);
		if (IS_ERR(rdev[i])) {
		if (IS_ERR(rdev)) {
			dev_err(&client->dev, "failed to register %s\n",
			dev_err(&client->dev, "failed to register %s\n",
				max1586_reg[id].name);
				max1586_reg[id].name);
			return PTR_ERR(rdev[i]);
			return PTR_ERR(rdev);
		}
		}
	}
	}


+8 −7
Original line number Original line Diff line number Diff line
@@ -65,7 +65,6 @@ enum max77686_ramp_rate {
};
};


struct max77686_data {
struct max77686_data {
	struct regulator_dev *rdev[MAX77686_REGULATORS];
	unsigned int opmode[MAX77686_REGULATORS];
	unsigned int opmode[MAX77686_REGULATORS];
};
};


@@ -400,7 +399,7 @@ static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
	unsigned int i;
	unsigned int i;


	pmic_np = iodev->dev->of_node;
	pmic_np = iodev->dev->of_node;
	regulators_np = of_find_node_by_name(pmic_np, "voltage-regulators");
	regulators_np = of_get_child_by_name(pmic_np, "voltage-regulators");
	if (!regulators_np) {
	if (!regulators_np) {
		dev_err(&pdev->dev, "could not find regulators sub-node\n");
		dev_err(&pdev->dev, "could not find regulators sub-node\n");
		return -EINVAL;
		return -EINVAL;
@@ -410,8 +409,7 @@ static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
	rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
	rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
			     pdata->num_regulators, GFP_KERNEL);
			     pdata->num_regulators, GFP_KERNEL);
	if (!rdata) {
	if (!rdata) {
		dev_err(&pdev->dev,
		of_node_put(regulators_np);
			"could not allocate memory for regulator data\n");
		return -ENOMEM;
		return -ENOMEM;
	}
	}


@@ -425,6 +423,7 @@ static int max77686_pmic_dt_parse_pdata(struct platform_device *pdev,
	}
	}


	pdata->regulators = rdata;
	pdata->regulators = rdata;
	of_node_put(regulators_np);


	return 0;
	return 0;
}
}
@@ -474,16 +473,18 @@ static int max77686_pmic_probe(struct platform_device *pdev)
	platform_set_drvdata(pdev, max77686);
	platform_set_drvdata(pdev, max77686);


	for (i = 0; i < MAX77686_REGULATORS; i++) {
	for (i = 0; i < MAX77686_REGULATORS; i++) {
		struct regulator_dev *rdev;

		config.init_data = pdata->regulators[i].initdata;
		config.init_data = pdata->regulators[i].initdata;
		config.of_node = pdata->regulators[i].of_node;
		config.of_node = pdata->regulators[i].of_node;


		max77686->opmode[i] = regulators[i].enable_mask;
		max77686->opmode[i] = regulators[i].enable_mask;
		max77686->rdev[i] = devm_regulator_register(&pdev->dev,
		rdev = devm_regulator_register(&pdev->dev,
						&regulators[i], &config);
						&regulators[i], &config);
		if (IS_ERR(max77686->rdev[i])) {
		if (IS_ERR(rdev)) {
			dev_err(&pdev->dev,
			dev_err(&pdev->dev,
				"regulator init failed for %d\n", i);
				"regulator init failed for %d\n", i);
			return PTR_ERR(max77686->rdev[i]);
			return PTR_ERR(rdev);
		}
		}
	}
	}


+11 −33
Original line number Original line Diff line number Diff line
@@ -34,13 +34,6 @@


#define CHGIN_ILIM_STEP_20mA			20000
#define CHGIN_ILIM_STEP_20mA			20000


struct max77693_pmic_dev {
	struct device *dev;
	struct max77693_dev *iodev;
	int num_regulators;
	struct regulator_dev **rdev;
};

/* CHARGER regulator ops */
/* CHARGER regulator ops */
/* CHARGER regulator uses two bits for enabling */
/* CHARGER regulator uses two bits for enabling */
static int max77693_chg_is_enabled(struct regulator_dev *rdev)
static int max77693_chg_is_enabled(struct regulator_dev *rdev)
@@ -170,19 +163,22 @@ static int max77693_pmic_dt_parse_rdata(struct device *dev,
	struct max77693_regulator_data *tmp;
	struct max77693_regulator_data *tmp;
	int i, matched = 0;
	int i, matched = 0;


	np = of_find_node_by_name(dev->parent->of_node, "regulators");
	np = of_get_child_by_name(dev->parent->of_node, "regulators");
	if (!np)
	if (!np)
		return -EINVAL;
		return -EINVAL;


	rmatch = devm_kzalloc(dev,
	rmatch = devm_kzalloc(dev,
		 sizeof(*rmatch) * ARRAY_SIZE(regulators), GFP_KERNEL);
		 sizeof(*rmatch) * ARRAY_SIZE(regulators), GFP_KERNEL);
	if (!rmatch)
	if (!rmatch) {
		of_node_put(np);
		return -ENOMEM;
		return -ENOMEM;
	}


	for (i = 0; i < ARRAY_SIZE(regulators); i++)
	for (i = 0; i < ARRAY_SIZE(regulators); i++)
		rmatch[i].name = regulators[i].name;
		rmatch[i].name = regulators[i].name;


	matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(regulators));
	matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(regulators));
	of_node_put(np);
	if (matched <= 0)
	if (matched <= 0)
		return matched;
		return matched;
	*rdata = devm_kzalloc(dev, sizeof(**rdata) * matched, GFP_KERNEL);
	*rdata = devm_kzalloc(dev, sizeof(**rdata) * matched, GFP_KERNEL);
@@ -229,7 +225,6 @@ static int max77693_pmic_init_rdata(struct device *dev,
static int max77693_pmic_probe(struct platform_device *pdev)
static int max77693_pmic_probe(struct platform_device *pdev)
{
{
	struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent);
	struct max77693_dev *iodev = dev_get_drvdata(pdev->dev.parent);
	struct max77693_pmic_dev *max77693_pmic;
	struct max77693_regulator_data *rdata = NULL;
	struct max77693_regulator_data *rdata = NULL;
	int num_rdata, i;
	int num_rdata, i;
	struct regulator_config config;
	struct regulator_config config;
@@ -240,39 +235,22 @@ static int max77693_pmic_probe(struct platform_device *pdev)
		return -ENODEV;
		return -ENODEV;
	}
	}


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

	max77693_pmic->rdev = devm_kzalloc(&pdev->dev,
				sizeof(struct regulator_dev *) * num_rdata,
				GFP_KERNEL);
	if (!max77693_pmic->rdev)
		return -ENOMEM;

	max77693_pmic->dev = &pdev->dev;
	max77693_pmic->iodev = iodev;
	max77693_pmic->num_regulators = num_rdata;

	config.dev = &pdev->dev;
	config.dev = &pdev->dev;
	config.regmap = iodev->regmap;
	config.regmap = iodev->regmap;
	config.driver_data = max77693_pmic;
	platform_set_drvdata(pdev, max77693_pmic);


	for (i = 0; i < max77693_pmic->num_regulators; i++) {
	for (i = 0; i < num_rdata; i++) {
		int id = rdata[i].id;
		int id = rdata[i].id;
		struct regulator_dev *rdev;


		config.init_data = rdata[i].initdata;
		config.init_data = rdata[i].initdata;
		config.of_node = rdata[i].of_node;
		config.of_node = rdata[i].of_node;


		max77693_pmic->rdev[i] = devm_regulator_register(&pdev->dev,
		rdev = devm_regulator_register(&pdev->dev,
						&regulators[id], &config);
						&regulators[id], &config);
		if (IS_ERR(max77693_pmic->rdev[i])) {
		if (IS_ERR(rdev)) {
			dev_err(max77693_pmic->dev,
			dev_err(&pdev->dev,
				"Failed to initialize regulator-%d\n", id);
				"Failed to initialize regulator-%d\n", id);
			return PTR_ERR(max77693_pmic->rdev[i]);
			return PTR_ERR(rdev);
		}
		}
	}
	}


+4 −4
Original line number Original line Diff line number Diff line
@@ -49,7 +49,6 @@
#define MAX8649_RAMP_DOWN	(1 << 1)
#define MAX8649_RAMP_DOWN	(1 << 1)


struct max8649_regulator_info {
struct max8649_regulator_info {
	struct regulator_dev	*regulator;
	struct device		*dev;
	struct device		*dev;
	struct regmap		*regmap;
	struct regmap		*regmap;


@@ -154,6 +153,7 @@ static int max8649_regulator_probe(struct i2c_client *client,
{
{
	struct max8649_platform_data *pdata = dev_get_platdata(&client->dev);
	struct max8649_platform_data *pdata = dev_get_platdata(&client->dev);
	struct max8649_regulator_info *info = NULL;
	struct max8649_regulator_info *info = NULL;
	struct regulator_dev *regulator;
	struct regulator_config config = { };
	struct regulator_config config = { };
	unsigned int val;
	unsigned int val;
	unsigned char data;
	unsigned char data;
@@ -234,12 +234,12 @@ static int max8649_regulator_probe(struct i2c_client *client,
	config.driver_data = info;
	config.driver_data = info;
	config.regmap = info->regmap;
	config.regmap = info->regmap;


	info->regulator = devm_regulator_register(&client->dev, &dcdc_desc,
	regulator = devm_regulator_register(&client->dev, &dcdc_desc,
						  &config);
						  &config);
	if (IS_ERR(info->regulator)) {
	if (IS_ERR(regulator)) {
		dev_err(info->dev, "failed to register regulator %s\n",
		dev_err(info->dev, "failed to register regulator %s\n",
			dcdc_desc.name);
			dcdc_desc.name);
		return PTR_ERR(info->regulator);
		return PTR_ERR(regulator);
	}
	}


	return 0;
	return 0;
+20 −15
Original line number Original line Diff line number Diff line
@@ -81,16 +81,17 @@ enum {
struct max8660 {
struct max8660 {
	struct i2c_client *client;
	struct i2c_client *client;
	u8 shadow_regs[MAX8660_N_REGS];		/* as chip is write only */
	u8 shadow_regs[MAX8660_N_REGS];		/* as chip is write only */
	struct regulator_dev *rdev[];
};
};


static int max8660_write(struct max8660 *max8660, u8 reg, u8 mask, u8 val)
static int max8660_write(struct max8660 *max8660, u8 reg, u8 mask, u8 val)
{
{
	static const u8 max8660_addresses[MAX8660_N_REGS] =
	static const u8 max8660_addresses[MAX8660_N_REGS] = {
	  { 0x10, 0x12, 0x20, 0x23, 0x24, 0x29, 0x2a, 0x32, 0x33, 0x39, 0x80 };
	 0x10, 0x12, 0x20, 0x23, 0x24, 0x29, 0x2a, 0x32, 0x33, 0x39, 0x80
	};


	int ret;
	int ret;
	u8 reg_val = (max8660->shadow_regs[reg] & mask) | val;
	u8 reg_val = (max8660->shadow_regs[reg] & mask) | val;

	dev_vdbg(&max8660->client->dev, "Writing reg %02x with %02x\n",
	dev_vdbg(&max8660->client->dev, "Writing reg %02x with %02x\n",
			max8660_addresses[reg], reg_val);
			max8660_addresses[reg], reg_val);


@@ -112,6 +113,7 @@ static int max8660_dcdc_is_enabled(struct regulator_dev *rdev)
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	u8 val = max8660->shadow_regs[MAX8660_OVER1];
	u8 val = max8660->shadow_regs[MAX8660_OVER1];
	u8 mask = (rdev_get_id(rdev) == MAX8660_V3) ? 1 : 4;
	u8 mask = (rdev_get_id(rdev) == MAX8660_V3) ? 1 : 4;

	return !!(val & mask);
	return !!(val & mask);
}
}


@@ -119,6 +121,7 @@ static int max8660_dcdc_enable(struct regulator_dev *rdev)
{
{
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	u8 bit = (rdev_get_id(rdev) == MAX8660_V3) ? 1 : 4;
	u8 bit = (rdev_get_id(rdev) == MAX8660_V3) ? 1 : 4;

	return max8660_write(max8660, MAX8660_OVER1, 0xff, bit);
	return max8660_write(max8660, MAX8660_OVER1, 0xff, bit);
}
}


@@ -126,15 +129,16 @@ static int max8660_dcdc_disable(struct regulator_dev *rdev)
{
{
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	u8 mask = (rdev_get_id(rdev) == MAX8660_V3) ? ~1 : ~4;
	u8 mask = (rdev_get_id(rdev) == MAX8660_V3) ? ~1 : ~4;

	return max8660_write(max8660, MAX8660_OVER1, mask, 0);
	return max8660_write(max8660, MAX8660_OVER1, mask, 0);
}
}


static int max8660_dcdc_get_voltage_sel(struct regulator_dev *rdev)
static int max8660_dcdc_get_voltage_sel(struct regulator_dev *rdev)
{
{
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	struct max8660 *max8660 = rdev_get_drvdata(rdev);

	u8 reg = (rdev_get_id(rdev) == MAX8660_V3) ? MAX8660_ADTV2 : MAX8660_SDTV2;
	u8 reg = (rdev_get_id(rdev) == MAX8660_V3) ? MAX8660_ADTV2 : MAX8660_SDTV2;
	u8 selector = max8660->shadow_regs[reg];
	u8 selector = max8660->shadow_regs[reg];

	return selector;
	return selector;
}
}


@@ -207,6 +211,7 @@ static int max8660_ldo67_is_enabled(struct regulator_dev *rdev)
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	u8 val = max8660->shadow_regs[MAX8660_OVER2];
	u8 val = max8660->shadow_regs[MAX8660_OVER2];
	u8 mask = (rdev_get_id(rdev) == MAX8660_V6) ? 2 : 4;
	u8 mask = (rdev_get_id(rdev) == MAX8660_V6) ? 2 : 4;

	return !!(val & mask);
	return !!(val & mask);
}
}


@@ -214,6 +219,7 @@ static int max8660_ldo67_enable(struct regulator_dev *rdev)
{
{
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	u8 bit = (rdev_get_id(rdev) == MAX8660_V6) ? 2 : 4;
	u8 bit = (rdev_get_id(rdev) == MAX8660_V6) ? 2 : 4;

	return max8660_write(max8660, MAX8660_OVER2, 0xff, bit);
	return max8660_write(max8660, MAX8660_OVER2, 0xff, bit);
}
}


@@ -221,15 +227,16 @@ static int max8660_ldo67_disable(struct regulator_dev *rdev)
{
{
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	u8 mask = (rdev_get_id(rdev) == MAX8660_V6) ? ~2 : ~4;
	u8 mask = (rdev_get_id(rdev) == MAX8660_V6) ? ~2 : ~4;

	return max8660_write(max8660, MAX8660_OVER2, mask, 0);
	return max8660_write(max8660, MAX8660_OVER2, mask, 0);
}
}


static int max8660_ldo67_get_voltage_sel(struct regulator_dev *rdev)
static int max8660_ldo67_get_voltage_sel(struct regulator_dev *rdev)
{
{
	struct max8660 *max8660 = rdev_get_drvdata(rdev);
	struct max8660 *max8660 = rdev_get_drvdata(rdev);

	u8 shift = (rdev_get_id(rdev) == MAX8660_V6) ? 0 : 4;
	u8 shift = (rdev_get_id(rdev) == MAX8660_V6) ? 0 : 4;
	u8 selector = (max8660->shadow_regs[MAX8660_L12VCR] >> shift) & 0xf;
	u8 selector = (max8660->shadow_regs[MAX8660_L12VCR] >> shift) & 0xf;

	return selector;
	return selector;
}
}


@@ -330,7 +337,7 @@ static int max8660_pdata_from_dt(struct device *dev,
	struct max8660_subdev_data *sub;
	struct max8660_subdev_data *sub;
	struct of_regulator_match rmatch[ARRAY_SIZE(max8660_reg)];
	struct of_regulator_match rmatch[ARRAY_SIZE(max8660_reg)];


	np = of_find_node_by_name(dev->of_node, "regulators");
	np = of_get_child_by_name(dev->of_node, "regulators");
	if (!np) {
	if (!np) {
		dev_err(dev, "missing 'regulators' subnode in DT\n");
		dev_err(dev, "missing 'regulators' subnode in DT\n");
		return -EINVAL;
		return -EINVAL;
@@ -340,6 +347,7 @@ static int max8660_pdata_from_dt(struct device *dev,
		rmatch[i].name = max8660_reg[i].name;
		rmatch[i].name = max8660_reg[i].name;


	matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(rmatch));
	matched = of_regulator_match(dev, np, rmatch, ARRAY_SIZE(rmatch));
	of_node_put(np);
	if (matched <= 0)
	if (matched <= 0)
		return matched;
		return matched;


@@ -373,7 +381,6 @@ static inline int max8660_pdata_from_dt(struct device *dev,
static int max8660_probe(struct i2c_client *client,
static int max8660_probe(struct i2c_client *client,
				   const struct i2c_device_id *i2c_id)
				   const struct i2c_device_id *i2c_id)
{
{
	struct regulator_dev **rdev;
	struct device *dev = &client->dev;
	struct device *dev = &client->dev;
	struct max8660_platform_data *pdata = dev_get_platdata(dev);
	struct max8660_platform_data *pdata = dev_get_platdata(dev);
	struct regulator_config config = { };
	struct regulator_config config = { };
@@ -406,14 +413,11 @@ static int max8660_probe(struct i2c_client *client,
		return -EINVAL;
		return -EINVAL;
	}
	}


	max8660 = devm_kzalloc(dev, sizeof(struct max8660) +
	max8660 = devm_kzalloc(dev, sizeof(struct max8660), GFP_KERNEL);
			sizeof(struct regulator_dev *) * MAX8660_V_END,
			GFP_KERNEL);
	if (!max8660)
	if (!max8660)
		return -ENOMEM;
		return -ENOMEM;


	max8660->client = client;
	max8660->client = client;
	rdev = max8660->rdev;


	if (pdata->en34_is_high) {
	if (pdata->en34_is_high) {
		/* Simulate always on */
		/* Simulate always on */
@@ -481,6 +485,7 @@ static int max8660_probe(struct i2c_client *client,


	/* Finally register devices */
	/* Finally register devices */
	for (i = 0; i < pdata->num_subdevs; i++) {
	for (i = 0; i < pdata->num_subdevs; i++) {
		struct regulator_dev *rdev;


		id = pdata->subdevs[i].id;
		id = pdata->subdevs[i].id;


@@ -489,13 +494,13 @@ static int max8660_probe(struct i2c_client *client,
		config.of_node = of_node[i];
		config.of_node = of_node[i];
		config.driver_data = max8660;
		config.driver_data = max8660;


		rdev[i] = devm_regulator_register(&client->dev,
		rdev = devm_regulator_register(&client->dev,
						  &max8660_reg[id], &config);
						  &max8660_reg[id], &config);
		if (IS_ERR(rdev[i])) {
		if (IS_ERR(rdev)) {
			ret = PTR_ERR(rdev[i]);
			ret = PTR_ERR(rdev);
			dev_err(&client->dev, "failed to register %s\n",
			dev_err(&client->dev, "failed to register %s\n",
				max8660_reg[id].name);
				max8660_reg[id].name);
			return PTR_ERR(rdev[i]);
			return PTR_ERR(rdev);
		}
		}
	}
	}


Loading