1. 06 5月, 2015 2 次提交
    • L
      pinctrl: move strict option to pinmux_ops · 8c4c2016
      Linus Walleij 提交于
      While the pinmux_ops are ideally just a vtable for pin mux
      calls, the "strict" setting belongs so intuitively with the
      pin multiplexing that we should move it here anyway. Putting
      it in the top pinctrl_desc makes no sense.
      
      Cc: Sonic Zhang <sonic.zhang@analog.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      8c4c2016
    • S
      pinctrl: allow exlusive GPIO/mux pin allocation · fa76a3db
      Sonic Zhang 提交于
      Disallow simultaneous use of the the GPIO and peripheral mux
      functions by setting a flag "strict" in struct pinctrl_desc.
      
      The blackfin pinmux and gpio controller doesn't allow user to
      set up a pin for both GPIO and peripheral function. So, add flag
      strict in struct pinctrl_desc to check both gpio_owner and
      mux_owner before approving the pin request.
      
      v2-changes:
      - if strict flag is set, check gpio_owner and mux_onwer in if and
        else clause
      
      v3-changes:
      - add kerneldoc for this struct
      - augment Documentation/pinctrl.txt
      Signed-off-by: NSonic Zhang <sonic.zhang@analog.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      fa76a3db
  2. 04 9月, 2014 1 次提交
  3. 11 7月, 2014 1 次提交
    • F
      pinctrl: avoid duplicated calling enable_pinmux_setting for a pin · 2243a87d
      Fan Wu 提交于
      What the patch does:
      1. Call pinmux_disable_setting ahead of pinmux_enable_setting
        each time pinctrl_select_state is called
      2. Remove the HW disable operation in pinmux_disable_setting function.
      3. Remove the disable ops in struct pinmux_ops
      4. Remove all the disable ops users in current code base.
      
      Notes:
      1. Great thanks for the suggestion from Linus, Tony Lindgren and
         Stephen Warren and Everyone that shared comments on this patch.
      2. The patch also includes comment fixes from Stephen Warren.
      
      The reason why we do this:
      1. To avoid duplicated calling of the enable_setting operation
         without disabling operation inbetween which will let the pin
         descriptor desc->mux_usecount increase monotonously.
      2. The HW pin disable operation is not useful for any of the
         existing platforms.
         And this can be used to avoid the HW glitch after using the
         item #1 modification.
      
      In the following case, the issue can be reproduced:
      1. There is a driver that need to switch pin state dynamically,
         e.g. between "sleep" and "default" state
      2. The pin setting configuration in a DTS node may be like this:
      
        component a {
      	pinctrl-names = "default", "sleep";
      	pinctrl-0 = <&a_grp_setting &c_grp_setting>;
      	pinctrl-1 = <&b_grp_setting &c_grp_setting>;
        }
      
        The "c_grp_setting" config node is totally identical, maybe like
        following one:
      
        c_grp_setting: c_grp_setting {
      	pinctrl-single,pins = <GPIO48 AF6>;
        }
      
      3. When switching the pin state in the following official pinctrl
         sequence:
      	pin = pinctrl_get();
      	state = pinctrl_lookup_state(wanted_state);
      	pinctrl_select_state(state);
      	pinctrl_put();
      
      Test Result:
      1. The switch is completed as expected, that is: the device's
         pin configuration is changed according to the description in the
         "wanted_state" group setting
      2. The "desc->mux_usecount" of the corresponding pins in "c_group"
         is increased without being decreased, because the "desc" is for
         each physical pin while the setting is for each setting node
         in the DTS.
         Thus, if the "c_grp_setting" in pinctrl-0 is not disabled ahead
         of enabling "c_grp_setting" in pinctrl-1, the desc->mux_usecount
         will keep increasing without any chance to be decreased.
      
      According to the comments in the original code, only the setting,
      in old state but not in new state, will be "disabled" (calling
      pinmux_disable_setting), which is correct logic but not intact. We
      still need consider case that the setting is in both old state
      and new state. We can do this in the following two ways:
      
      1. Avoid to "enable"(calling pinmux_enable_setting) the "same pin
         setting" repeatedly
      2. "Disable"(calling pinmux_disable_setting) the "same pin setting",
         actually two setting instances, ahead of enabling them.
      
      Analysis:
      1. The solution #2 is better because it can avoid too much
         iteration.
      2. If we disable all of the settings in the old state and one of
         the setting(s) exist in the new state, the pins mux function
         change may happen when some SoC vendors defined the
         "pinctrl-single,function-off"
         in their DTS file.
         old_setting => disabled_setting => new_setting.
      3. In the pinmux framework, when a pin state is switched, the
         setting in the old state should be marked as "disabled".
      
      Conclusion:
      1. To Remove the HW disabling operation to above the glitch mentioned
         above.
      2. Handle the issue mentioned above by disabling all of the settings
         in old state and then enable the all of the settings in new state.
      Signed-off-by: NFan Wu <fwu@marvell.com>
      Acked-by: NStephen Warren <swarren@nvidia.com>
      Acked-by: NPatrice Chotard <patrice.chotard@st.com>
      Acked-by: NHeiko Stuebner <heiko@sntech.de>
      Acked-by: NMaxime Coquelin <maxime.coquelin@st.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      2243a87d
  4. 22 4月, 2014 1 次提交
    • A
      pinctrl: allows not to define the get_group_pins operation · e5b3b2d9
      Antoine Ténart 提交于
      When using a group only pinctrl driver, which does not have any
      information on the pins it is useless to define a get_group_pins
      always returning an empty list of pins.
      
      When not using get_group_pin[1], a driver must implement it so
      pins = NULL and num_pins = 0. This patch makes it the default
      behaviour if not defined in the pinctrl driver when used in
      pinmux enable and disable funtions and in pinctrl_groups_show.
      
      It also adds a check in pinctrl_get_group_pins and return -EINVAL if
      not defined. This function is called in the gpiolib when adding when
      pingroup range. It cannot be used if no group is defined, so this seams
      reasonable.
      
      [1] get_group_pin(struct pinctrl_dev *pctldev,
      		  unsigned selector,
      		  const unsigned **pins,
      		  unsigned *num_pins);
      Signed-off-by: NAntoine Ténart <antoine.tenart@free-electrons.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      e5b3b2d9
  5. 04 11月, 2013 1 次提交
  6. 15 8月, 2013 1 次提交
  7. 14 8月, 2013 1 次提交
  8. 26 4月, 2013 1 次提交
    • P
      pinctrl: move subsystem mutex to pinctrl_dev struct · 42fed7ba
      Patrice Chotard 提交于
      This mutex avoids deadlock in case of use of multiple pin
      controllers. Before this modification, by using a global
      mutex, deadlock appeared when, for example, a call to
      pinctrl_pins_show() locked the pinctrl_mutex, called the
      ops->pin_dbg_show of a particular pin controller. If this
      pin controller needs I2C access to retrieve configuration
      information and I2C driver is using pinctrl to drive its
      pins, a call to pinctrl_select_state() try to lock again
      pinctrl_mutex which leads to a deadlock.
      
      Notice that the mutex grab from the two direction functions
      was moved into pinctrl_gpio_direction().
      
      For several cases, we can't replace pinctrl_mutex by
      pctldev->mutex, because at this stage, pctldev is
      not accessible :
      	- pinctrl_get()/pinctrl_put()
      	- pinctrl_register_maps()
      
      So add respectively pinctrl_list_mutex and
      pinctrl_maps_mutex in order to protect
      pinctrl_list and pinctrl_maps list instead.
      
      Reintroduce pinctrldev_list_mutex in
      find_pinctrl_by_of_node(),
      pinctrl_find_and_add_gpio_range()
      pinctrl_request_gpio(), pinctrl_free_gpio(),
      pinctrl_gpio_direction(), pinctrl_devices_show(),
      pinctrl_register() and pinctrl_unregister() to
      protect pinctrldev_list.
      
      Changes v2->v3:
      - Fix a missing EXPORT_SYMBOL_GPL() for pinctrl_select_state().
      
      Changes v1->v2:
      - pinctrl_select_state_locked() is removed, all lock mechanism
        is located inside pinctrl_select_state(). When parsing
        the state->setting list, take the per-pin-controller driver
        lock. (Patrice).
      - Introduce pinctrldev_list_mutex to protect pinctrldev_list
        in all functions which parse or modify pictrldev_list.
        (Patrice).
      - move find_pinctrl_by_of_node() from pinctrl/devicetree.c to
        pinctrl/core.c in order to protect pinctrldev_list.
        (Patrice).
      - Sink mutex:es into some functions and remove some _locked
        variants down to where the lists are actually accessed to
        make things simpler. (Linus)
      - Drop *all* mutexes completely from pinctrl_lookup_state()
        and pinctrl_select_state() - no relevant mutex was taken
        and it was unclear what this was protecting against. (Linus)
      
      Reported by : Seraphin Bonnaffe <seraphin.bonnaffe@stericsson.com>
      Signed-off-by: NPatrice Chotard <patrice.chotard@st.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      42fed7ba
  9. 22 3月, 2013 1 次提交
  10. 12 11月, 2012 2 次提交
    • A
      pinctrl: pinmux: Release all taken pins in pinmux_enable_setting error paths · e38d457d
      Axel Lin 提交于
      Currently pinmux_enable_setting does not release all taken pins if
      ops->enable() returns error. This patch ensures all taken pins are
      released in any error paths.
      Signed-off-by: NAxel Lin <axel.lin@ingics.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      e38d457d
    • L
      pinctrl: reserve pins when states are activated · 1a78958d
      Linus Walleij 提交于
      This switches the way that pins are reserved for multiplexing:
      
      We used to do this when the map was parsed, at the creation of
      the settings inside the pinctrl handle, in pinmux_map_to_setting().
      
      However this does not work for us, because we want to use the
      same set of pins with different devices at different times: the
      current code assumes that the pin groups in a pinmux state will
      only be used with one single device, albeit different groups can
      be active at different times. For example if a single I2C driver
      block is used to drive two different busses located on two
      pin groups A and B, then the pins for all possible states of a
      function are reserved when fetching the pinctrl handle: the
      I2C bus can choose either set A or set B by a mux state at
      runtime, but all pins in both group A and B (the superset) are
      effectively reserved for that I2C function and mapped to the
      device. Another device can never get in and use the pins in
      group A, even if the device/function is using group B at the
      moment.
      
      Instead: let use reserve the pins when the state is activated
      and drop them when the state is disabled, i.e. when we move to
      another state. This way different devices/functions can use the
      same pins at different times.
      
      We know that this is an odd way of doing things, but we really
      need to switch e.g. an SD-card slot to become a tracing output
      sink at runtime: we plug in a special "tracing card" then mux
      the pins that used to be an SD slot around to the tracing
      unit and push out tracing data there instead of SD-card
      traffic.
      
      As a side effect pinmux_free_setting() is unused but the stubs
      are kept for future additions of code.
      
      Cc: Patrice Chotard <patrice.chotard@st.com>
      Cc: Loic Pallardy <loic.pallardy@st.com>
      Acked-by: NStephen Warren <swarren@nvidia.com>
      Tested-by: NJean Nicolas Graux <jean-nicolas.graux@stericsson.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      1a78958d
  11. 14 9月, 2012 1 次提交
  12. 15 5月, 2012 1 次提交
  13. 07 5月, 2012 1 次提交
  14. 27 4月, 2012 1 次提交
    • J
      pinctrl: enhance reporting of errors when loading from DT · ad6e1107
      John Crispin 提交于
      There are a few places in the api where the code simply returns -EINVAL when
      it finds an error. An example is pinmux_map_to_setting() which now reports an
      error if we try to match a group with a function that it does not support.
      
      The reporting of errors in pinconf_check_ops and pinmux_check_ops now has the
      same style and is located inside the according functions and not the calling
      code.
      
      When the map is found in the DT but the default state can not be selected we
      get an error to know that the code at least tried.
      
      The patch also removes a stray word from one comment and a "->" from another
      for the sake of consistency.
      
      Finally we replace a few pr_err/debug() calls with dev_err/dbg().
      
      Thanks go to Stephen Warren for reviewing the patch and enhancing the reporting
      inside pinmux_map_to_setting().
      Signed-off-by: NJohn Crispin <blogic@openwrt.org>
      Acked-by: NStephen Warren <swarren@wwwdotorg.org>
      Cc: linux-kernel@vger.kernel.org
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      ad6e1107
  15. 24 4月, 2012 1 次提交
  16. 18 4月, 2012 4 次提交
  17. 13 3月, 2012 1 次提交
    • S
      pinctrl: allow concurrent gpio and mux function ownership of pins · 652162d4
      Stephen Warren 提交于
      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: NStephen Warren <swarren@nvidia.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      652162d4
  18. 05 3月, 2012 5 次提交
    • S
      pinctrl: Show selected function and group in pinmux-pins debugfs · ba110d90
      Stephen Warren 提交于
      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 <linus.walleij@linaro.org>
      Signed-off-by: NStephen Warren <swarren@nvidia.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      ba110d90
    • S
      pinctrl: enhance mapping table to support pin config operations · 1e2082b5
      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: NStephen Warren <swarren@nvidia.com>
      Acked-by: NDong Aisheng <dong.aisheng@linaro.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      1e2082b5
    • S
      pinctrl: add usecount to pins for muxing · 0e3db173
      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: NStephen Warren <swarren@nvidia.com>
      Acked-by: NDong Aisheng <dong.aisheng@linaro.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      0e3db173
    • S
      pinctrl: refactor struct pinctrl handling in core.c vs pinmux.c · 7ecdb16f
      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: NStephen Warren <swarren@nvidia.com>
      Acked-by: NLinus Walleij <linus.walleij@linaro.org>
      Acked-by: NDong Aisheng <dong.aisheng@linaro.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      7ecdb16f
    • S
      pinctrl: fix and simplify locking · 57b676f9
      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: NStephen Warren <swarren@nvidia.com>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      57b676f9
  19. 02 3月, 2012 1 次提交
  20. 01 3月, 2012 1 次提交
  21. 24 2月, 2012 1 次提交
  22. 23 2月, 2012 3 次提交
  23. 11 2月, 2012 2 次提交
  24. 02 2月, 2012 1 次提交
  25. 26 1月, 2012 3 次提交
  26. 25 1月, 2012 1 次提交