Skip to content

Commit

Permalink
mfd: twl4030-power: Add support for board specific configuration
Browse files Browse the repository at this point in the history
With the recommended twl4030 configuration added, we can now add
board specific changes as modifications to the recommended
configuration.

Note that the data is private to this driver, and the data must
always have a NULL resource in the sentinel.

Signed-off-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
  • Loading branch information
Tony Lindgren authored and Lee Jones committed May 28, 2014
1 parent 76714d2 commit 482e7db
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
21 changes: 21 additions & 0 deletions drivers/mfd/twl4030-power.c
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,34 @@ twl4030_power_configure_scripts(const struct twl4030_power_data *pdata)
return 0;
}

static void twl4030_patch_rconfig(struct twl4030_resconfig *common,
struct twl4030_resconfig *board)
{
while (common->resource) {
struct twl4030_resconfig *b = board;

while (b->resource) {
if (b->resource == common->resource) {
*common = *b;
break;
}
b++;
}
common++;
}
}

static int
twl4030_power_configure_resources(const struct twl4030_power_data *pdata)
{
struct twl4030_resconfig *resconfig = pdata->resource_config;
struct twl4030_resconfig *boardconf = pdata->board_config;
int err;

if (resconfig) {
if (boardconf)
twl4030_patch_rconfig(resconfig, boardconf);

while (resconfig->resource) {
err = twl4030_configure_resource(resconfig);
if (err)
Expand Down
1 change: 1 addition & 0 deletions include/linux/i2c/twl.h
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ struct twl4030_power_data {
struct twl4030_script **scripts;
unsigned num;
struct twl4030_resconfig *resource_config;
struct twl4030_resconfig *board_config;
#define TWL4030_RESCONFIG_UNDEF ((u8)-1)
bool use_poweroff; /* Board is wired for TWL poweroff */
};
Expand Down

0 comments on commit 482e7db

Please sign in to comment.