2 * Driver core interface to the pinctrl subsystem.
4 * Copyright (C) 2012 ST-Ericsson SA
5 * Written on behalf of Linaro for ST-Ericsson
6 * Based on bits of regulator core, gpio core and clk core
8 * Author: Linus Walleij <linus.walleij@linaro.org>
10 * License terms: GNU General Public License (GPL) version 2
13 #include <linux/device.h>
14 #include <linux/pinctrl/devinfo.h>
15 #include <linux/pinctrl/consumer.h>
16 #include <linux/slab.h>
19 * pinctrl_bind_pins() - called by the device core before probe
20 * @dev: the device that is just about to probe
22 int pinctrl_bind_pins(struct device
*dev
)
26 dev
->pins
= devm_kzalloc(dev
, sizeof(*(dev
->pins
)), GFP_KERNEL
);
30 dev
->pins
->p
= devm_pinctrl_get(dev
);
31 if (IS_ERR(dev
->pins
->p
)) {
32 dev_dbg(dev
, "no pinctrl handle\n");
33 ret
= PTR_ERR(dev
->pins
->p
);
37 dev
->pins
->default_state
= pinctrl_lookup_state(dev
->pins
->p
,
38 PINCTRL_STATE_DEFAULT
);
39 if (IS_ERR(dev
->pins
->default_state
)) {
40 dev_dbg(dev
, "no default pinctrl state\n");
45 ret
= pinctrl_select_state(dev
->pins
->p
, dev
->pins
->default_state
);
47 dev_dbg(dev
, "failed to activate default pinctrl state\n");
54 * If no pinctrl handle or default state was found for this device,
55 * let's explicitly free the pin container in the device, there is
56 * no point in keeping it around.
59 devm_pinctrl_put(dev
->pins
->p
);
61 devm_kfree(dev
, dev
->pins
);
64 /* Only return deferrals */
65 if (ret
!= -EPROBE_DEFER
)