11 Dec, 2018

12 commits

  • The GPIO descriptors used by the DA9211 driver are retrieved
    during probe() and it is really helpful to have those under
    devres management because of all the errorpaths in the
    intialization.

    Using the new dev_gpiod_unhinge() call we can remove the
    devres management of the descriptor right before handing
    it over to the regulators core.

    Signed-off-by: Linus Walleij
    Reviewed-by: Marek Szyprowski
    Reviewed-by: Charles Keepax
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • The probe path of this driver is a bit complex: sometimes the
    GPIO descriptor is passed to the regulator core, sometimes
    it is not.

    To handle it in a simple way: stick with the devm_* resource
    management and unhinge the GPIO descriptor devres handling
    right before passing it to the regulator core, if we pass it
    to the regulator core.

    Fixes: e7d2be696faa ("regulator: max8973: Pass descriptor instead of GPIO number")
    Signed-off-by: Linus Walleij
    Reviewed-by: Marek Szyprowski
    Reviewed-by: Charles Keepax
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • This adds a function named devm_gpiod_unhinge() that removes
    the resource management from a GPIO descriptor.

    I am not sure if this is the best anglosaxon name for the
    function, no other managed resources have an equivalent
    currently, but I chose "unhinge" as the closest intuitive
    thing I could imagine that fits Rusty Russell's API design
    criterions "the obvious use is the correct one" and
    "the name tells you how to use it".

    The idea came out of a remark from Mark Brown that it should
    be possible to handle over management of a resource from
    devres to the regulator core, and indeed we can do that.

    Signed-off-by: Linus Walleij
    Reviewed-by: Marek Szyprowski
    Tested-by: Marek Szyprowski
    Reviewed-by: Charles Keepax
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • When we get a nonexeclusive GPIO descriptor using managed
    resources, we should only add it to the list of managed
    resources once: on the first user. Augment the
    devm_gpiod_get_index() and devm_gpiod_get_from_of_node()
    calls to account for this by checking if the descriptor
    is already resource managed before we proceed to allocate
    a new resource management struct.

    Fixes: b0ce7b29bfcd ("regulator/gpio: Allow nonexclusive GPIO access")
    Reported-by: Marek Szyprowski
    Signed-off-by: Linus Walleij
    Reviewed-by: Marek Szyprowski
    Tested-by: Marek Szyprowski
    Reviewed-by: Charles Keepax
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • This makes gpiod_get_from_of_node() respect the
    GPIOD_FLAGS_BIT_NONEXCLUSIVE flag which is especially
    nice when getting regulator GPIOs right out of device
    tree nodes.

    Suggested-by: Marek Szyprowski
    Fixes: b0ce7b29bfcd ("regulator/gpio: Allow nonexclusive GPIO access")
    Signed-off-by: Linus Walleij
    Reviewed-by: Marek Szyprowski
    Tested-by: Marek Szyprowski
    Reviewed-by: Charles Keepax
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • Use the gpiod_get_from_of_node() rather than the devm_*
    version so that the regulator core can handle the lifecycle
    of these descriptors.

    Fix up the errorpath so that we free this descriptor if
    an error occurs in the callback. Rely on the regulator
    core to deal with it after this point: a previous patch
    fixed up the regulator core to properly dispose any
    GPIO descriptors once you call regulator_register().

    Fixes: 96392c3d8ca4 ("regulator: max77686: Pass descriptor instead of GPIO number")
    Signed-off-by: Linus Walleij
    Reviewed-by: Marek Szyprowski
    Tested-by: Marek Szyprowski
    Reviewed-by: Charles Keepax
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • This function already exist inside gpiolib, we were just
    reluctant to make it available to the kernel at large as
    the devm_* seemed to be enough for anyone.

    However we found out that regulators need to do their own
    lifecycle/refcounting on GPIO descriptors and explicitly
    call gpiod_put() when done with a descriptor, so export
    this function so we can hand the refcounting over to the
    regulator core for these descriptors after retrieveal.

    Signed-off-by: Linus Walleij
    Reviewed-by: Marek Szyprowski
    Tested-by: Marek Szyprowski
    Reviewed-by: Charles Keepax
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • Use the gpiod_get() rather than the devm_* version so that the
    regulator core can handle the lifecycle of these descriptors.

    Fixes: d7a261c2d1f2 ("regulator: max8952: Pass descriptor instead of GPIO number")
    Signed-off-by: Linus Walleij
    Reviewed-by: Marek Szyprowski
    Tested-by: Marek Szyprowski
    Reviewed-by: Charles Keepax
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • Use the gpiod_get() rather than the devm_* version so that the
    regulator core can handle the lifecycle of these descriptors.

    Fixes: 2468f0d51548 ("regulator: lp8788-ldo: Pass descriptor instead of GPIO number")
    Signed-off-by: Linus Walleij
    Reviewed-by: Marek Szyprowski
    Reviewed-by: Charles Keepax
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • Use the gpiod_get() rather than the devm_* version so that the
    regulator core can handle the lifecycle of these descriptors.

    Fixes: b2d751b7f69b ("regulator: lm363x: Pass descriptor instead of GPIO number")
    Signed-off-by: Linus Walleij
    Reviewed-by: Marek Szyprowski
    Reviewed-by: Charles Keepax
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • Use the gpiod_get() rather than the devm_* version so that the
    regulator core can handle the lifecycle of these descriptors.

    Fixes: efdfeb079cc3 ("regulator: fixed: Convert to use GPIO descriptor only")
    Signed-off-by: Linus Walleij
    Reviewed-by: Marek Szyprowski
    Tested-by: Marek Szyprowski
    Reviewed-by: Charles Keepax
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • If a GPIO descriptor is passed to the regulator_register()
    function inside the config->ena_gpiod callers must be
    sure that once they call this API the regulator core
    owns that descriptor and will make sure to issue
    gpiod_put() on it, no matter whether the call is
    successful or not.

    For device tree regulators, the regulator core will
    automatically set up regulator init data from the device
    tree when registering a regulator by calling
    regulator_of_get_init_data() which in turn calls down to
    the regulator driver's .of_parse_cb() callback.
    This callback (in drivers such as for max77686) may also
    choose to fill in the config->ena_gpiod field with a GPIO
    descriptor.

    Harden the errorpath of regulator_register() to
    properly gpiod_put() any passed in cfg->ena_gpiod
    or any gpiod coming from the device tree on any type
    of error.

    Signed-off-by: Linus Walleij
    Reviewed-by: Marek Szyprowski
    Tested-by: Marek Szyprowski
    Reviewed-by: Charles Keepax
    Signed-off-by: Mark Brown

    Linus Walleij
     

07 Dec, 2018

1 commit

  • Convert string compares of DT node names to use of_node_name_eq helper
    instead. This removes direct access to the node name pointer.

    For instances using of_node_cmp, this has the side effect of now using
    case sensitive comparisons. This should not matter for any FDT based
    system which all of these are.

    Cc: Liam Girdwood
    Cc: Mark Brown
    Cc: Support Opensource
    Cc: Sangbeom Kim
    Cc: Krzysztof Kozlowski
    Cc: Bartlomiej Zolnierkiewicz
    Cc: linux-samsung-soc@vger.kernel.org
    Signed-off-by: Rob Herring
    Acked-by: Adam Thomson
    Signed-off-by: Mark Brown

    Rob Herring
     

05 Dec, 2018

2 commits


03 Dec, 2018

1 commit


27 Nov, 2018

1 commit

  • Prior to commit 5451781dadf8 ("regulator: core: Only count load for
    enabled consumers") we used to always add up the total load on every
    enable in _regulator_enable(). After that commit we only updated the
    total load when enabling / disabling a regulator where a consumer
    specified a load or when changing the consumer load on an enabled
    regulator.

    The problem with the new scheme is that if there is a system load
    specified for a regulator but no consumers specify a load then we
    never account for it.

    Let's account for the system load in set_machine_constraints().

    NOTE: with the new scheme we end up with a bit of a quandry. What if
    someone specifies _both_ an initial mode and a system load? If we
    take the system load into account right at init time then it will
    effectively clobber the initial mode. We'll resolve this by saying
    that if both are specified then the initial mode will win. The system
    load will then only take effect if/when a consumer specifies a load.
    If no consumers ever specify a load then the initial mode will persist
    and the system load will have no effect.

    Fixes: 5451781dadf8 ("regulator: core: Only count load for enabled consumers")
    Reported-by: Brian Masney
    Signed-off-by: Douglas Anderson
    Tested-by: Brian Masney
    Signed-off-by: Mark Brown

    Douglas Anderson
     

22 Nov, 2018

3 commits

  • Address remaining comments from original driver patch series

    * Move RD_FIFO_CFG to be ordered corretly
    * Expand spinlock comment

    Signed-off-by: Ryan Case
    Reviewed-by: Stephen Boyd
    Reviewed-by: Douglas Anderson
    Signed-off-by: Mark Brown

    Ryan Case
     
  • When we called regulator_enable() on a regulator we'd end up
    propagating that call all the way up the chain every time. This is a
    bit of a waste of time. A child regulator already refcounts its own
    enables so it should avoid passing on to its parent unless the
    refcount transitioned between 0 and 1.

    Historically this hasn't been a huge problem since we skipped dealing
    with enable for always-on regulators. In a previous patch, however,
    we removed the always-on optimization. On one system, the debugfs
    regulator_summary was now showing a "use_count" of 33 for a top-level
    regulator.

    Let's implement this optimization. This turns out to be fairly
    trivial with the recent reorganization of the regulator core.

    NOTE: as part of this patch I'll make "always-on" regulators start
    with a use count of 1. This keeps the counts clean when recursively
    resolving regulators.

    ALSO NOTE: this commit also contains somewhat of a bug fix to
    regulator_force_disable(). It was incorrectly looping over
    "rdev->open_count" when it should have been looping over use_count.
    We have to touch that code anyway (since we should no longer loop at
    all), so we'll fix it together in one patch. Also: since this comes
    after commit f8702f9e4aa7 ("regulator: core: Use ww_mutex for
    regulators locking") we can now move to use _regulator_disable() for
    our supply and keep it in the lock.

    Signed-off-by: Douglas Anderson
    Signed-off-by: Mark Brown

    Douglas Anderson
     
  • In general when the consumer of a regulator requests that the
    regulator be disabled it no longer will be drawing much load from the
    regulator--it should just be the leakage current and that should be
    very close to 0.

    Up to this point the regulator framework has continued to count a
    consumer's load request for disabled regulators. This has led to code
    patterns that look like this:

    enable_my_thing():
    regular_set_load(reg, load_uA)
    regulator_enable(reg)

    disable_my_thing():
    regulator_disable(reg)
    regulator_set_load(reg, 0)

    Sometimes disable_my_thing() sets a nominal (
    Signed-off-by: Mark Brown

    Douglas Anderson
     

21 Nov, 2018

2 commits


20 Nov, 2018

3 commits


19 Nov, 2018

5 commits


16 Nov, 2018

4 commits

  • when the VIR_LDO1 regulator supplier is it's brother,
    we can't find the supplier.

    example code :
    &vir_regulator {
    ldo0_vir: ldo0-virtual {
    regulator-compatible = "VIR_LDO0";
    regulator-name= "VIR_LDO0";
    regulator-min-microvolt = ;
    regulator-max-microvolt = ;
    };
    ldo1_vir: ldo1-virtual {
    regulator-compatible = "VIR_LDO1";
    regulator-name= "VIR_LDO1";
    regulator-min-microvolt = ;
    regulator-max-microvolt = ;
    ldo1-supply = ;
    };
    ...
    }

    so we add the child ptah to find the suppier.

    Signed-off-by: zoro
    Signed-off-by: Mark Brown

    zoro
     
  • Instead of passing a global GPIO number, pass a descriptor looked
    up from the device tree configuration node.

    Tested on Odroid U3 (with max77686 although not using any GPIOs
    for regulators, so at least default paths are not broken).

    Cc: Chanwoo Choi
    Cc: Krzysztof Kozlowski
    Cc: Bartlomiej Zolnierkiewicz
    Reviewed-by: Krzysztof Kozlowski
    Tested-by: Krzysztof Kozlowski
    Signed-off-by: Linus Walleij
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • Instead of passing a global GPIO number for the enable GPIO, pass
    a descriptor looked up from the device tree node or the board file
    decriptor table for the regulator.

    There is a single board file passing the GPIOs for LDO1 and LDO2
    through platform data, so augment this to pass descriptors
    associated with the i2c device as well.

    The special GPIO enable DT property for the enable GPIO is
    nonstandard but this was accomodated in
    commit 6a537d48461deacc57c07ed86d9915e5aa4b3539
    "gpio: of: Support regulator nonstandard GPIO properties".

    Cc: patches@opensource.cirrus.com
    Acked-by: Charles Keepax
    Acked-by: Lee Jones
    Signed-off-by: Linus Walleij
    Signed-off-by: Mark Brown

    Linus Walleij
     
  • Instead of passing a global GPIO number for the enable GPIO, pass
    a descriptor looked up with the standard devm_gpiod_get_optional()
    call.

    This regulator supports passing platform data, but enable/sleep
    regulators are looked up from the device tree exclusively, so
    we can need not touch other files.

    Tested on Odroid XU3 (with s2mps11 although not using any GPIOs
    for regulators, so at least default paths are not broken).

    Cc: Sangbeom Kim
    Cc: Chanwoo Choi
    Cc: Bartlomiej Zolnierkiewicz
    Cc: Krzysztof Kozlowski
    Reviewed-by: Krzysztof Kozlowski
    Tested-by: Krzysztof Kozlowski
    Signed-off-by: Linus Walleij
    Signed-off-by: Mark Brown

    Linus Walleij
     

14 Nov, 2018

6 commits