14 Sep, 2016

1 commit

  • strict pin controller returns -EINVAL in case of pin request which
    is already claimed by somebody else.
    Following is the sequence of calling pin_request() from
    pinctrl_bind_pins():-
    pinctrl_bind_pins()->pinctrl_select_state()->pinmux_enable_setting()->
    pin_request()

    But pinctrl_bind_pins() only returns -EPROBE_DEFER which makes device
    driver probe successful even if the pin request is rejected by the pin
    controller subsystem.

    This commit modifies pinctrl_bind_pins() to return error if the pin is
    rejected by pin control subsystem.

    Signed-off-by: Deepak Das
    [Rewrote to be cleaner]
    Signed-off-by: Linus Walleij

    Deepak
     

27 Oct, 2015

1 commit

  • For pinctrl the "default" state is applied to pins before the driver's
    probe function is called. This is normally a sensible thing to do,
    but in some cases can cause problems. That's because the pins will
    change state before the driver is given a chance to program how those
    pins should behave.

    As an example you might have a regulator that is controlled by a PWM
    (output high = high voltage, output low = low voltage). The firmware
    might leave this pin as driven high. If we allow the driver core to
    reconfigure this pin as a PWM pin before the PWM's probe function runs
    then you might end up running at too low of a voltage while we probe.

    Let's introudce a new "init" state. If this is defined we'll set
    pinctrl to this state before probe and then "default" after probe
    (unless the driver explicitly changed states already).

    An alternative idea that was thought of was to use the pre-existing
    "sleep" or "idle" states and add a boolean property that we should
    start in that mode. This was not done because the "init" state is
    needed for correctness and those other states are only present (and
    only transitioned in to and out of) when (optional) power management
    is enabled.

    Changes in v3:
    - Moved declarations to pinctrl/devinfo.h
    - Fixed author/SoB

    Changes in v2:
    - Added comment to pinctrl_init_done() as per Linus W.

    Signed-off-by: Douglas Anderson
    Acked-by: Greg Kroah-Hartman
    Tested-by: Caesar Wang
    Signed-off-by: Linus Walleij

    Douglas Anderson
     

16 Jun, 2013

1 commit

  • If a device have sleep and idle states in addition to the
    default state, look up these in the core and stash them in
    the pinctrl state container.

    Add accessor functions for pinctrl consumers to put the pins
    into "default", "sleep" and "idle" states passing nothing but
    the struct device * affected.

    Solution suggested by Kevin Hilman, Mark Brown and Dmitry
    Torokhov in response to a patch series from Hebbar
    Gururaja.

    Cc: Hebbar Gururaja
    Cc: Dmitry Torokhov
    Cc: Stephen Warren
    Acked-by: Wolfram Sang
    Acked-by: Greg Kroah-Hartman
    Reviewed-by: Mark Brown
    Reviewed-by: Kevin Hilman
    Signed-off-by: Linus Walleij

    Linus Walleij
     

23 Jan, 2013

1 commit

  • This makes the device core auto-grab the pinctrl handle and set
    the "default" (PINCTRL_STATE_DEFAULT) state for every device
    that is present in the device model right before probe. This will
    account for the lion's share of embedded silicon devcies.

    A modification of the semantics for pinctrl_get() is also done:
    previously if the pinctrl handle for a certain device was already
    taken, the pinctrl core would return an error. Now, since the
    core may have already default-grabbed the handle and set its
    state to "default", if the handle was already taken, this will
    be disregarded and the located, previously instanitated handle
    will be returned to the caller.

    This way all code in drivers explicitly requesting their pinctrl
    handlers will still be functional, and drivers that want to
    explicitly retrieve and switch their handles can still do that.
    But if the desired functionality is just boilerplate of this
    type in the probe() function:

    struct pinctrl *p;

    p = devm_pinctrl_get_select_default(&dev);
    if (IS_ERR(p)) {
    if (PTR_ERR(p) == -EPROBE_DEFER)
    return -EPROBE_DEFER;
    dev_warn(&dev, "no pinctrl handle\n");
    }

    The discussion began with the addition of such boilerplate
    to the omap4 keypad driver:
    http://marc.info/?l=linux-input&m=135091157719300&w=2

    A previous approach using notifiers was discussed:
    http://marc.info/?l=linux-kernel&m=135263661110528&w=2
    This failed because it could not handle deferred probes.

    This patch alone does not solve the entire dilemma faced:
    whether code should be distributed into the drivers or
    if it should be centralized to e.g. a PM domain. But it
    solves the immediate issue of the addition of boilerplate
    to a lot of drivers that just want to grab the default
    state. As mentioned, they can later explicitly retrieve
    the handle and set different states, and this could as
    well be done by e.g. PM domains as it is only related
    to a certain struct device * pointer.

    ChangeLog v4->v5 (Stephen):
    - Simplified the devicecore grab code.
    - Deleted a piece of documentation recommending that pins
    be mapped to a device rather than hogged.
    ChangeLog v3->v4 (Linus):
    - Drop overzealous NULL checks.
    - Move kref initialization to pinctrl_create().
    - Seeking Tested-by from Stephen Warren so we do not disturb
    the Tegra platform.
    - Seeking ACK on this from Greg (and others who like it) so I
    can merge it through the pinctrl subsystem.
    ChangeLog v2->v3 (Linus):
    - Abstain from using IS_ERR_OR_NULL() in the driver core,
    Russell recently sent a patch to remove it. Handle the
    NULL case explicitly even though it's a bogus case.
    - Make sure we handle probe deferral correctly in the device
    core file. devm_kfree() the container on error so we don't
    waste memory for devices without pinctrl handles.
    - Introduce reference counting into the pinctrl core using
    so that we don't release pinctrl handles
    that have been obtained for two or more places.
    ChangeLog v1->v2 (Linus):
    - Only store a pointer in the device struct, and only allocate
    this if it's really used by the device.

    Cc: Felipe Balbi
    Cc: Benoit Cousson
    Cc: Dmitry Torokhov
    Cc: Thomas Petazzoni
    Cc: Mitch Bradley
    Cc: Ulf Hansson
    Cc: Rafael J. Wysocki
    Cc: Jean-Christophe PLAGNIOL-VILLARD
    Cc: Rickard Andersson
    Cc: Russell King
    Reviewed-by: Mark Brown
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: Linus Walleij
    [swarren: fixed and simplified error-handling in pinctrl_bind_pins(), to
    correctly handle deferred probe. Removed admonition from docs not to use
    pinctrl hogs for devices]
    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Linus Walleij