Skip to content

Commit

Permalink
pinctrl: Enable device link creation for pin control
Browse files Browse the repository at this point in the history
A pin controller may want to create a link between itself
and its clients to be sure of suspend/resume call ordering.

Introduce link_consumers field in pinctrl_desc structure to let
pinctrl core knows that controller expect to create a link.

Signed-off-by: Benjamin Gaignard <benjamin.gaignard@st.com>
[Renamed create_link to link_consumers]
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Benjamin Gaignard authored and Linus Walleij committed May 23, 2019
1 parent ee11f86 commit 036f394
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
11 changes: 11 additions & 0 deletions drivers/pinctrl/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,15 @@ struct pinctrl_state *pinctrl_lookup_state(struct pinctrl *p,
}
EXPORT_SYMBOL_GPL(pinctrl_lookup_state);

static void pinctrl_link_add(struct pinctrl_dev *pctldev,
struct device *consumer)
{
if (pctldev->desc->link_consumers)
device_link_add(consumer, pctldev->dev,
DL_FLAG_PM_RUNTIME |
DL_FLAG_AUTOREMOVE_CONSUMER);
}

/**
* pinctrl_commit_state() - select/activate/program a pinctrl state to HW
* @p: the pinctrl handle for the device that requests configuration
Expand Down Expand Up @@ -1261,6 +1270,8 @@ static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
if (ret < 0) {
goto unapply_new_state;
}

pinctrl_link_add(setting->pctldev, p->dev);
}

p->state = state;
Expand Down
5 changes: 5 additions & 0 deletions include/linux/pinctrl/pinctrl.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ struct pinctrl_ops {
* the hardware description
* @custom_conf_items: Information how to print @params in debugfs, must be
* the same size as the @custom_params, i.e. @num_custom_params
* @link_consumers: If true create a device link between pinctrl and its
* consumers (i.e. the devices requesting pin control states). This is
* sometimes necessary to ascertain the right suspend/resume order for
* example.
*/
struct pinctrl_desc {
const char *name;
Expand All @@ -139,6 +143,7 @@ struct pinctrl_desc {
const struct pinconf_generic_params *custom_params;
const struct pin_config_item *custom_conf_items;
#endif
bool link_consumers;
};

/* External interface to pin controller */
Expand Down

0 comments on commit 036f394

Please sign in to comment.