11 Apr, 2012

1 commit

  • Most code assumes that the pinctrl ops are present. Validate this when
    registering a pinctrl driver. Remove the one place in the code that
    was checking whether one of these non-optional ops was present.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     

13 Mar, 2012

5 commits

  • This adds pin configuration support for the U300 driver pair,
    we can now read out the biasing and drive mode in debugfs and
    configure it using the new configuration API.

    ChangeLog v1->v2:
    - Migrate to pin config and generic pin config changes.
    ChangeLog v2->v3:
    - Adjust to generic pin config changes in v7 patch set.

    Signed-off-by: Linus Walleij

    Linus Walleij
     
  • Adjust the COH 901 driver to use the standard enums for
    biasing and driving pins, alter signature of config function
    to suit the framework.

    Signed-off-by: Linus Walleij

    Linus Walleij
     
  • This is a split-off from the earlier patch set which adds generic
    pin configuration for the pin controllers that want it. Since
    we may have a system with mixed generic and custom pin controllers,
    we pass a boolean in the pin controller ops vtable to indicate
    if it is generic.

    ChangeLog v1->v5:
    - Follow parent patch versioning number system.
    - Document the semantic meaning of return values from pin config
    get functions, so we can iterate over pins and check their
    properties from debugfs as part of the generic config code.
    - Use proper cast functions in the generic debugfs pin config
    file.
    - Expand generic config to optionally cover groups too.
    ChangeLog v5->v6:
    - Update to match underlying changes.
    ChangeLog v6->v7:
    - Drop DRIVE_OFF parameter, use bias high impedance for this
    - Delete argument for drive modes push-pull, od and os. These
    are now just state transitions.
    - Delete slew rate rising/falling due to discussions on on
    proper semantics
    - Drop config wakeup, struct irq_chip does this for now, add
    back if need be.
    - Set PIN_CONFIG_END to 0x7fff making room for custom config
    parameters from 0x8000 and up.
    - Prefix accessor functions with pinconf_

    Linus Walleij
     
  • The code was using the union member
    setting->data.configs.group_or_pin to store a potential
    error code, but since that member is unsigned the
    < 0 comparison was not true, letting errors pass through,
    ending up as mapped to pin "-22". Fix this up and print
    the error.

    Acked-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Linus Walleij
     
  • Per recent updates to Documentation/gpio.txt, gpiolib drivers should
    inform pinctrl when a GPIO is requested. pinctrl then marks that pin as
    in-use for that GPIO function.

    When an SoC muxes pins in a group, it's quite possible for the group to
    contain e.g. 6 pins, but only 4 of them actually be needed by the HW
    module that's mux'd to them. In this case, the other 2 pins could be
    used as GPIOs. However, pinctrl marks all the pins within the group as
    in-use by the selected mux function. To allow the expected gpiolib
    interaction, separate the concepts of pin ownership into two parts: One
    for the mux function and one for GPIO usage. Finally, allow those two
    ownerships to exist in parallel.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     

07 Mar, 2012

2 commits


06 Mar, 2012

1 commit

  • This adds a driver for the Tegra pinmux, and required parameterization
    data for Tegra20 and Tegra30.

    The driver is initially added with driver name and device tree compatible
    value that won't cause this driver to be used. A later change will switch
    the pinctrl driver to use the correct values, switch the old pinmux
    driver to be disabled, and update all code that uses the old pinmux APIs
    to use the new pinctrl APIs.

    Signed-off-by: Stephen Warren
    Acked-by: Olof Johansson
    [squashed "fix case of Tegra30's foo_groups[] arrays"]
    Signed-off-by: Linus Walleij

    Stephen Warren
     

05 Mar, 2012

6 commits

  • Until recently, the pinctrl pinmux-pins debugfs file displayed the
    selected function for each owned pin. This feature was removed during
    restructing in support of recent API rework. This change restoreds this
    feature, and also displays the group that the function was selected on,
    in case a pin is a member of multiple groups.

    Based on work by: Linus Walleij

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • The pinctrl mapping table can now contain entries to:
    * Set the mux function of a pin group
    * Apply a set of pin config options to a pin or a group

    This allows pinctrl_select_state() to apply pin configs settings as well
    as mux settings.

    v3: Fix find_pinctrl() to iterate over the correct list.
    s/_MUX_CONFIGS_/_CONFIGS_/ in mapping table macros.
    Fix documentation to use correct mapping table macro.
    v2: Added numerous extra PIN_MAP_*() special-case macros.
    Fixed kerneldoc typo. Delete pinctrl_get_pin_id() and
    replace it with pin_get_from_name(). Various minor fixes.
    Updates due to rebase.

    Signed-off-by: Stephen Warren
    Acked-by: Dong Aisheng
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • The API model is changed from:

    p = pinctrl_get(dev, "state1");
    pinctrl_enable(p);
    ...
    pinctrl_disable(p);
    pinctrl_put(p);
    p = pinctrl_get(dev, "state2");
    pinctrl_enable(p);
    ...
    pinctrl_disable(p);
    pinctrl_put(p);

    to this:

    p = pinctrl_get(dev);
    s1 = pinctrl_lookup_state(p, "state1");
    s2 = pinctrl_lookup_state(p, "state2");
    pinctrl_select_state(p, s1);
    ...
    pinctrl_select_state(p, s2);
    ...
    pinctrl_put(p);

    This allows devices to directly transition between states without
    disabling the pin controller programming and put()/get()ing the
    configuration data each time. This model will also better suit pinconf
    programming, which doesn't have a concept of "disable".

    The special-case hogging feature of pin controllers is re-written to use
    the regular APIs instead of special-case code. Hence, the pinmux-hogs
    debugfs file is removed; see the top-level pinctrl-handles files for
    equivalent data.

    Signed-off-by: Stephen Warren
    Acked-by: Dong Aisheng
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • Multiple mapping table entries could reference the same pin, and hence
    "own" it. This would be unusual now that pinctrl_get() represents a single
    state for a client device, but in the future when it represents all known
    states for a device, this is quite likely. Implement reference counting
    for pin ownership to handle this.

    Signed-off-by: Stephen Warren
    Acked-by: Dong Aisheng
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • This change separates two aspects of struct pinctrl:

    a) The data representation of the parsed mapping table, into:

    1) The top-level struct pinctrl object, a single entity returned
    by pinctrl_get().

    2) The parsed version of each mapping table entry, struct
    pinctrl_setting, of which there is one per mapping table entry.

    b) The code that handles this; the code for (1) above is in core.c, and
    the code to parse/execute each entry in (2) above is in pinmux.c, while
    the iteration over multiple settings is lifted to core.c.

    This will allow the following future changes:

    1) pinctrl_get() API rework, so that struct pinctrl represents all states
    for the device, and the device can select between them without calling
    put()/get() again.

    2) To support that, a struct pinctrl_state object will be inserted into
    the data model between the struct pinctrl and struct pinctrl_setting.

    3) The mapping table will be extended to allow specification of pin config
    settings too. To support this, struct pinctrl_setting will be enhanced
    to store either mux settings or config settings, and functions will be
    added to pinconf.c to parse/execute pin configuration settings.

    Signed-off-by: Stephen Warren
    Acked-by: Linus Walleij
    Acked-by: Dong Aisheng
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • There are many problems with the current pinctrl locking:

    struct pinctrl_dev's gpio_ranges_lock isn't effective;
    pinctrl_match_gpio_range() only holds this lock while searching for a gpio
    range, but the found range is return and manipulated after releading the
    lock. This could allow pinctrl_remove_gpio_range() for that range while it
    is in use, and the caller may very well delete the range after removing it,
    causing pinctrl code to touch the now-free range object.

    Solving this requires the introduction of a higher-level lock, at least
    a lock per pin controller, which both gpio range registration and
    pinctrl_get()/put() will acquire.

    There is missing locking on HW programming; pin controllers may pack the
    configuration for different pins/groups/config options/... into one
    register, and hence have to read-modify-write the register. This needs to
    be protected, but currently isn't. Related, a future change will add a
    "complete" op to the pin controller drivers, the idea being that each
    state's programming will be programmed into the pinctrl driver followed
    by the "complete" call, which may e.g. flush a register cache to HW. For
    this to work, it must not be possible to interleave the pinctrl driver
    calls for different devices.

    As above, solving this requires the introduction of a higher-level lock,
    at least a lock per pin controller, which will be held for the duration
    of any pinctrl_enable()/disable() call.

    However, each pinctrl mapping table entry may affect a different pin
    controller if necessary. Hence, with a per-pin-controller lock, almost
    any pinctrl API may need to acquire multiple locks, one per controller.
    To avoid deadlock, these would need to be acquired in the same order in
    all cases. This is extremely difficult to implement in the case of
    pinctrl_get(), which doesn't know which pin controllers to lock until it
    has parsed the entire mapping table, since it contains somewhat arbitrary
    data.

    The simplest solution here is to introduce a single lock that covers all
    pin controllers at once. This will be acquired by all pinctrl APIs.

    This then makes struct pinctrl's mutex irrelevant, since that single lock
    will always be held whenever this mutex is currently held.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     

02 Mar, 2012

4 commits

  • The introduction of the owner field on the pin descriptor was not
    properly documented so fix this up.

    Signed-off-by: Linus Walleij

    Linus Walleij
     
  • pinctrl_register_mappings() already requires that every mapping table
    entry have a non-NULL name field.

    Logically, this makes sense too; drivers should always request a specific
    named state so they know what they're getting. Relying on getting the
    first mentioned state in the mapping table is error-prone, and a nasty
    special case to implement, given that a given the mapping table may define
    multiple states for a device.

    Remove a small part of the documentation that talked about optionally
    requesting a specific state; it's mandatory now.

    Signed-off-by: Stephen Warren
    Acked-by: Dong Aisheng
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • This provides a single centralized name for the default state.

    Update PIN_MAP_* macros to use this state name, instead of requiring the
    user to pass a state name in.

    With this change, hog entries in the mapping table are defined as those
    with state name PINCTRL_STATE_DEFAULT, i.e. all entries have the same
    name. This interacts badly with the nested iteration over mapping table
    entries in pinctrl_hog_maps() and pinctrl_hog_map() which would now
    attempt to claim each hog mapping table entry multiple times. Replacing
    the custom hog code with a simple pinctrl_get()/pinctrl_enable().

    Update documentation and mapping tables to use this.

    Signed-off-by: Stephen Warren
    Acked-by: Dong Aisheng
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • At present, pinctrl_get() assumes that all matching mapping table entries
    have the same "function" value, albeit potentially applied to different
    pins/groups.

    This change removes this restriction; pinctrl_get() can now handle a set
    of mapping tables where different functions are applied to the various
    pins/groups.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     

01 Mar, 2012

2 commits

  • The debugfs file pinctrl-maps is a system-wide file, not specific to any
    pin controller, so place it in the top-level directory.

    Also, move the code implementing the file to keep the order of all the
    functions matching the order they're created in pinctrl_init_*debugfs().
    The only non-obvious change here is no private data is passed to
    debugfs_create_file() or single_open().

    Signed-off-by: Stephen Warren
    Acked-by: Dong Aisheng
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • The debugfs file pinmux-pins used to tell which function was
    enabled but now states simply which device owns the pin. Being
    owned by the pinctrl driver itself means just that it's hogged
    so be a bit more helpful by printing that.

    ChangeLog v1->v2:
    - Preserve the self-referential owner field, just clarify that
    when the pin controller states itself as owner this means
    that it's hogged.

    Acked-by: Dong Aisheng
    Acked-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Linus Walleij
     

24 Feb, 2012

4 commits

  • struct pinctrl_dev's pin_desc_tree_lock and pinctrl_hogs_lock aren't
    useful; the data they protect is read-only except when registering or
    unregistering a pinctrl_dev, and at those times, it doesn't make sense to
    protect one part of the structure independently from the rest.

    Move pinctrl_init_device_debugfs() to the end of pinctrl_register() so
    that debugfs can't access the struct pinctrl_dev until it's fully
    initialized, i.e. after the hogs are set up.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • This hopefully makes it harder to take the sizeof the wrong type.

    Signed-off-by: Stephen Warren
    Acked-by: Dong Aisheng
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • e.g. dev_err instead of pr_err prints messages in a slightly more
    standardized format.

    Also, add a few more error messages to track down errors.

    Also, some small cleanups of messages.

    Signed-off-by: Stephen Warren
    Acked-by: Dong Aisheng
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • Hog entries are mapping table entries with .ctrl_dev_name == .dev_name.
    All other mapping table entries need .dev_name set so that they will
    match some pinctrl_get() call. All extant PIN_MAP*() macros set
    .dev_name.

    So, there is no reason to allow mapping table entries without .dev_name
    set. Update the code and documentation to disallow this.

    Signed-off-by: Stephen Warren
    Acked-by: Dong Aisheng
    Signed-off-by: Linus Walleij

    Stephen Warren
     

23 Feb, 2012

13 commits

  • pinconf_groups_show() wrote all debug information on one line. Fix it to
    match pinconf_pins_show() and be legible.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • When pins are requested/acquired/got, some device becomes the owner of
    their mux setting. At this point, it isn't certain which mux function
    will be selected for the pin, since this may vary between each of the
    device's states in the pinctrl mapping table. As such, we should record
    the owning device, not what we think the initial mux setting will be,
    when requesting pins.

    This doesn't make a lot of difference right now since pinctrl_get gets
    only one single device/state combination, but this will make a difference
    when pinctrl_get gets all states, and pinctrl_select_state can switch
    between states.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • This is a serious error, and the pin control system will not function
    correctly if it ends up not programing the mapping table entries into
    the HW. Instead of just ignoring this, error out.

    Signed-off-by: Stephen Warren
    [rebased to fit the applied patch series, cast error to pointer]
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • This may be perfectly legitimate. An IP block may get re-used
    across SoCs. Not all of those SoCs may need pinmux settings for the
    IP block, e.g. if one SoC dedicates pins to that function but
    another doesn't. The driver won't know this, and will always
    attempt to set up the pinmux. The mapping table defines whether any
    HW programming is actually needed.

    Acked-by: Shawn Guo
    Signed-off-by: Stephen Warren
    [rebased to fit the applied patch series]
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • These are already disallowed. Clean up some code that doesn't assume this.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • This solves the riddle on how the U300 pin controller shall be
    able to reference the struct gpio_chip even though these are
    two separate drivers: spawn the pinctrl child from the GPIO
    driver and pass in the struct gpio_chip as platform data.
    In the process we rename the U300 "pinmux-u300" to
    "pinctrl-u300" so as not to confuse.

    Signed-off-by: Linus Walleij

    Linus Walleij
     
  • * Make all functions internal to core.c static. Remove any of these from
    core.h.
    * Add any missing EXPORT_SYMBOL_GPL().

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • Modify the two files so that the order of function prototypes in the
    header matches the order of implementations in the .c file.

    Don't prototype a couple of internal functions.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • Modify the two files so that the order of function prototypes in the
    header matches the order of implementations in the .c file.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • Instead of storing a single array of mapping table entries, which
    requires realloc()ing that array each time it's extended and copying
    the new data, simply store a list of pointers to the individual chunks.
    This also removes the need to copy the mapping table at all; a pointer
    is maintained to the original table, this saving memory.

    A macro for_each_maps() is introduced to hide the additional complexity
    of iterating over the map entries.

    This change will also simplify removing chunks of entries from the mapping
    table. This isn't important right now, but will be in the future, when
    mapping table entries are dynamically added when parsing them from the
    device tree, and removed when drivers no longer need to interact with
    pinctrl.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • This mostly makes debugfs files print things in the order that they
    were added or acquired, which just feels a little more consistent.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • It may be common for pinctrl_register_mappings() to be used from __init
    context, but there's no reason that additional mappings shouldn't be
    added at a later point, e.g. if loading modules that add pin controllers
    and their mapping tables.

    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     
  • Commit 77a5988 "pinctrl: changes hog mechanism to be self-referential"
    modified the way "hog" entries were represented in the mapping table.
    However, the new representation failed some error checks in
    pinctrl_hog_map(). Remove the now-bogus error-check, and fix the code
    to solve the issue the error-check used to avoid.

    Acked-by: Dong Aisheng
    Signed-off-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Stephen Warren
     

11 Feb, 2012

2 commits

  • Instead of a specific boolean field to indicate if a map entry shall
    be hogged, treat self-reference as an indication of desired hogging.
    This drops one field off the map struct and has a nice Douglas R.
    Hofstadter-feel to it.

    Acked-by: Dong Aisheng
    Acked-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Linus Walleij
     
  • This moves the per-devices struct pinctrl handles and device map
    over from the pinmux part of the subsystem to the core pinctrl part.
    This makes the device handles core infrastructure with the goal of
    using these handles also for pin configuration, so that device
    drivers (or boards etc) will need one and only one handle to the
    pin control core.

    Acked-by: Stephen Warren
    Signed-off-by: Linus Walleij

    Linus Walleij