Skip to content

Commit

Permalink
regulator: arizona-micsupp: Move pdata into a separate structure
Browse files Browse the repository at this point in the history
In preparation for sharing this driver with Madera, move the pdata
for the micsupp regulator out of struct arizona_pdata into a dedicated
pdata struct for this driver. As a result the code in
arizona_micsupp_of_get_pdata() can be made independent of struct arizona.

This patch also updates the definition of struct arizona_pdata and
the use of this pdata in mach-crag6410-module.c

Signed-off-by: Richard Fitzgerald <[email protected]>
Acked-by: Lee Jones <[email protected]>
Signed-off-by: Mark Brown <[email protected]>
  • Loading branch information
Richard Fitzgerald authored and broonie committed Apr 25, 2017
1 parent 7e64259 commit 22161f3
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 11 deletions.
1 change: 1 addition & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -13623,6 +13623,7 @@ F: include/linux/mfd/arizona/
F: include/linux/mfd/wm831x/
F: include/linux/mfd/wm8350/
F: include/linux/mfd/wm8400*
F: include/linux/regulator/arizona*
F: include/linux/wm97xx.h
F: include/sound/wm????.h
F: sound/soc/codecs/arizona.?
Expand Down
21 changes: 11 additions & 10 deletions drivers/regulator/arizona-micsupp.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <linux/mfd/arizona/pdata.h>
#include <linux/mfd/arizona/registers.h>

#include <linux/regulator/arizona-micsupp.h>

struct arizona_micsupp {
struct regulator_dev *regulator;
struct arizona *arizona;
Expand Down Expand Up @@ -199,28 +201,26 @@ static const struct regulator_init_data arizona_micsupp_ext_default = {
.num_consumer_supplies = 1,
};

static int arizona_micsupp_of_get_pdata(struct device *dev,
struct arizona *arizona,
static int arizona_micsupp_of_get_pdata(struct arizona_micsupp_pdata *pdata,
struct regulator_config *config,
const struct regulator_desc *desc)
{
struct arizona_pdata *pdata = &arizona->pdata;
struct arizona_micsupp *micsupp = config->driver_data;
struct device_node *np;
struct regulator_init_data *init_data;

np = of_get_child_by_name(arizona->dev->of_node, "micvdd");
np = of_get_child_by_name(config->dev->of_node, "micvdd");

if (np) {
config->of_node = np;

init_data = of_get_regulator_init_data(dev, np, desc);
init_data = of_get_regulator_init_data(config->dev, np, desc);

if (init_data) {
init_data->consumer_supplies = &micsupp->supply;
init_data->num_consumer_supplies = 1;

pdata->micvdd = init_data;
pdata->init_data = init_data;
}
}

Expand All @@ -232,6 +232,7 @@ static int arizona_micsupp_probe(struct platform_device *pdev)
struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
const struct regulator_desc *desc;
struct regulator_config config = { };
struct arizona_micsupp_pdata *pdata = &arizona->pdata.micvdd;
struct arizona_micsupp *micsupp;
int ret;

Expand Down Expand Up @@ -269,15 +270,15 @@ static int arizona_micsupp_probe(struct platform_device *pdev)

if (IS_ENABLED(CONFIG_OF)) {
if (!dev_get_platdata(arizona->dev)) {
ret = arizona_micsupp_of_get_pdata(&pdev->dev, arizona,
&config, desc);
ret = arizona_micsupp_of_get_pdata(pdata, &config,
desc);
if (ret < 0)
return ret;
}
}

if (arizona->pdata.micvdd)
config.init_data = arizona->pdata.micvdd;
if (pdata->init_data)
config.init_data = pdata->init_data;
else
config.init_data = &micsupp->init_data;

Expand Down
3 changes: 2 additions & 1 deletion include/linux/mfd/arizona/pdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#define _ARIZONA_PDATA_H

#include <dt-bindings/mfd/arizona.h>
#include <linux/regulator/arizona-micsupp.h>

#define ARIZONA_GPN_DIR_MASK 0x8000 /* GPN_DIR */
#define ARIZONA_GPN_DIR_SHIFT 15 /* GPN_DIR */
Expand Down Expand Up @@ -79,7 +80,7 @@ struct arizona_pdata {
int ldoena; /** GPIO controlling LODENA, if any */

/** Regulator configuration for MICVDD */
struct regulator_init_data *micvdd;
struct arizona_micsupp_pdata micvdd;

/** Regulator configuration for LDO1 */
struct regulator_init_data *ldo1;
Expand Down
21 changes: 21 additions & 0 deletions include/linux/regulator/arizona-micsupp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* Platform data for Arizona micsupp regulator
*
* Copyright 2017 Cirrus Logic
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*/

#ifndef ARIZONA_MICSUPP_H
#define ARIZONA_MICSUPP_H

struct regulator_init_data;

struct arizona_micsupp_pdata {
/** Regulator configuration for micsupp */
const struct regulator_init_data *init_data;
};

#endif

0 comments on commit 22161f3

Please sign in to comment.