1. 17 5月, 2018 9 次提交
    • M
      regulator: core: Add voltage balancing mechanism · 69686176
      Maciej Purski 提交于
      On Odroid XU3/4 and other Exynos5422 based boards there is a case, that
      different devices on the board are supplied by different regulators
      with non-fixed voltages. If one of these devices temporarily requires
      higher voltage, there might occur a situation that the spread between
      two devices' voltages is so high, that there is a risk of changing
      'high' and 'low' states on the interconnection between devices powered
      by those regulators.
      
      Introduce new function regulator_balance_voltage(), which
      keeps max_spread constraint fulfilled between a group of coupled
      regulators. It should be called if a regulator changes its
      voltage or after disabling or enabling. Disabled regulators should
      follow changes of the enabled ones, but their consumers' demands
      shouldn't be taken into account while calculating voltage of other
      coupled regulators.
      
      Find voltages, which are closest to suiting all the consumers' demands,
      while fulfilling max_spread constraint, keeping the following rules:
      - if one regulator is about to rise its voltage, rise others
        voltages in order to keep the max_spread
      - if a regulator, which has caused rising other regulators, is
        lowered, lower other regulators if possible
      - if one regulator is about to lower its voltage, but it hasn't caused
        rising other regulators, don't change its voltage if it breaks the
        max_spread
      
      Change regulators' voltages step by step, keeping max_spread constraint
      fulfilled all the time. Function regulator_get_optimal_voltage()
      should find the best possible change for the regulator, which doesn't
      break max_spread constraint. In function regulator_balance_voltage()
      optimize number of steps by finding highest voltage difference on
      each iteration.
      
      If a regulator, which is about to change its voltage, is not coupled,
      method regulator_get_optimal_voltage() should simply return the lowest
      voltage fulfilling consumers' demands.
      
      Coupling should be checked only if the system is in PM_SUSPEND_ON state.
      Signed-off-by: NMaciej Purski <m.purski@samsung.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      69686176
    • M
      regulator: core: Resolve coupled regulators · d3d64537
      Maciej Purski 提交于
      On Odroid XU3/4 and other Exynos5422 based boards there is a case, that
      different devices on the board are supplied by different regulators
      with non-fixed voltages. If one of these devices temporarily requires
      higher voltage, there might occur a situation that the spread between
      two devices' voltages is so high, that there is a risk of changing
      'high' and 'low' states on the interconnection between devices powered
      by those regulators.
      
      Fill coupling descriptor with data obtained from DTS using previously
      defined of_functions. Fail to register a regulator, if some data
      inconsistency occurs. If some coupled regulators are not yet registered,
      don't fail to register, but try to resolve them in late init call.
      Signed-off-by: NMaciej Purski <m.purski@samsung.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      d3d64537
    • M
      regulator: core: Parse coupled regulators properties · a085a31a
      Maciej Purski 提交于
      On Odroid XU3/4 and other Exynos5422 based boards there is a case, that
      different devices on the board are supplied by different regulators
      with non-fixed voltages. If one of these devices temporarily requires
      higher voltage, there might occur a situation that the spread between
      devices' voltages is so high, that there is a risk of changing
      'high' and 'low' states on the interconnection between devices powered
      by those regulators.
      
      Add new structure "coupling_desc" to regulator_dev, which contains
      pointers to all coupled regulators including the owner of the structure,
      number of coupled regulators and counter of currently resolved
      regulators.
      
      Add of_functions to parse all data needed in regulator coupling.
      Provide method to check DTS data consistency. Check if each coupled
      regulator's max_spread is equal and if their lists of regulators match.
      Signed-off-by: NMaciej Purski <m.purski@samsung.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      a085a31a
    • M
      regulator: core: Make locks re-entrant · 66cf9a7e
      Maciej Purski 提交于
      Setting voltage, enabling/disabling regulators requires operations on
      all regulators related with the regulator being changed. Therefore,
      all of them should be locked for the whole operation. With the current
      locking implementation, adding additional dependency (regulators
      coupling) causes deadlocks in some cases.
      
      Introduce a possibility to attempt to lock a mutex multiple times
      by the same task without waiting on a mutex. This should handle all
      reasonable coupling-supplying combinations, especially when two coupled
      regulators share common supplies. The only situation that should be
      forbidden is simultaneous coupling and supplying between a pair of
      regulators.
      
      The idea is based on clk core.
      Signed-off-by: NMaciej Purski <m.purski@samsung.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      66cf9a7e
    • L
      regulator: s2mps11: Pass descriptor instead of GPIO number · 0369e02b
      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.
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Reviewed-by: NKrzysztof Kozlowski <krzk@kernel.org>
      Tested-by: NKrzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      0369e02b
    • L
      regulator: max77686: Pass descriptor instead of GPIO number · c89c00e2
      Linus Walleij 提交于
      Instead of passing a global GPIO number, pass a descriptor looked
      up from the device tree configuration node.
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Reviewed-by: NKrzysztof Kozlowski <krzk@kernel.org>
      Tested-by: NKrzysztof Kozlowski <krzk@kernel.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      c89c00e2
    • L
      regulator: arizona-ldo1: Look up a descriptor and pass to the core · e1739e86
      Linus Walleij 提交于
      Instead of passing a global GPIO number, pass a descriptor looked
      up with the standard devm_gpiod_get_optional() call.
      
      We have augmented the GPIO core to look up the regulator special
      GPIO "wlf,ldoena" in commit 6a537d48
      "gpio: of: Support regulator nonstandard GPIO properties".
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Acked-by: NCharles Keepax <ckeepax@opensource.wolfsonmicro.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      e1739e86
    • D
      regulator: of: add support for allowed modes configuration · 54557ad9
      David Collins 提交于
      Add support for configuring the machine constraints
      valid_modes_mask element based on a list of allowed modes
      specified via a device tree property.
      Signed-off-by: NDavid Collins <collinsd@codeaurora.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      54557ad9
    • D
      regulator: core: Allow for regulators that can't be read at bootup · 84b3a7c9
      Douglas Anderson 提交于
      Regulators attached via RPMh on Qualcomm sdm845 apparently are
      write-only.  Specifically you can send a request for a certain voltage
      but you can't read back to see what voltage you've requested.  What
      this means is that at bootup we have absolutely no idea what voltage
      we could be at.
      
      As discussed in the patches to try to support the RPMh regulators [1],
      the fact that regulators are write-only means that its driver's
      get_voltage_sel() should return an error code if it's called before
      any calls to set_voltage_sel().  This causes problems in
      machine_constraints_voltage() when trying to apply the constraints.
      
      A proposed fix was to come up with an error code that could be
      returned by get_voltage_sel() which would cause the regulator
      framework to simply try setting the voltage with the current
      constraints.
      
      In this patch I propose the error code -ENOTRECOVERABLE.  In errno.h
      this error is described as "State not recoverable".  Though the error
      code was originally intended "for robust mutexes", the description of
      the error code seems to apply here because we can't read the state of
      the regulator.  Also note that the only existing user of this error
      code in the regulator framework is tps65090-regulator.c which returns
      this error code from the enable() call (not get_voltage() or
      get_voltage_sel()), so there should be no existing regulators that
      might accidentally get the new behavior.  (Side note is that tps65090
      seems to interpret this error code to mean an error that you can't
      recover from rather than some data that can't be recovered).
      
      [1] https://patchwork.kernel.org/patch/10340897/Signed-off-by: NDouglas Anderson <dianders@chromium.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      84b3a7c9
  2. 09 5月, 2018 1 次提交
  3. 05 5月, 2018 1 次提交
    • C
      regulator: add dummy function of_find_regulator_by_node · 08813e0e
      Changbin Du 提交于
      If device tree is not enabled, of_find_regulator_by_node() should have
      a dummy function since the function call is still there.
      
      This is to fix build error after CONFIG_NO_AUTO_INLINE is introduced.
      If this option is enabled, GCC will not auto-inline functions that are
      not explicitly marked as inline.
      
      In this case (no CONFIG_OF), the copmiler will report error in function
      regulator_dev_lookup().
      
      W/O NO_AUTO_INLINE, function of_get_regulator() is auto-inlined and then
      the call to of_find_regulator_by_node() is optimized out since
      of_get_regulator() always return NULL.
      
      W/ NO_AUTO_INLINE, the return value of of_get_regulator() is a variable
      so the call to of_find_regulator_by_node() cannot be optimized out. So
      we need a stub of_find_regulator_by_node().
      
      static struct regulator_dev *regulator_dev_lookup(struct device *dev,
      						  const char *supply)
      {
      	struct regulator_dev *r = NULL;
      	struct device_node *node;
      	struct regulator_map *map;
      	const char *devname = NULL;
      
      	regulator_supply_alias(&dev, &supply);
      
      	/* first do a dt based lookup */
      	if (dev && dev->of_node) {
      		node = of_get_regulator(dev, supply);
      		if (node) {
      			r = of_find_regulator_by_node(node);
      			if (r)
      				return r;
      	...
      Signed-off-by: NChangbin Du <changbin.du@intel.com>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      08813e0e
  4. 24 4月, 2018 1 次提交
    • G
      regulator: bd9571mwv: Add support for backup mode · 6eb0bfae
      Geert Uytterhoeven 提交于
      The BD9571MWV PMIC supports backup mode, which keeps one or more DDR
      rails powered while the main SoC is powered down.
      
      Which DDR rails are to be kept powered is board-specific, and controlled
      using the optional "rohm,ddr-backup-power" DT property.  In the absence
      of this property, backup mode is not available.
      
      Backup mode can be enabled or disabled by the user using the standard
      "wakeup" virtual file in sysfs, e.g. to enable:
      
          echo enabled > /sys/devices/platform/soc/e60b0000.i2c/i2c-7/7-0030/bd9571mwv-regulator.2.auto/power/wakeup
      
      When the PMIC is configured for backup mode, the role of the accessory
      power switch changes from a power switch to a wake-up switch.
      Two types of switches (or signals) can be used:
        A. With a momentary power switch (or pulse signal), the PMIC is
           configured for backup mode in the PMIC driver's suspend callback,
           during system suspend.
           Backup mode is enabled by default, as there is no further impact
           during normal system operation.
      
        B. With a toggle power switch (or level signal), the following steps
           must be followed exactly:
             1. Configure PMIC for backup mode,
             2. Switch accessory power switch off, to prepare for system
                suspend, which is a manual step not controlled by software,
             3. Suspend system.
           This mode is not yet supported by the driver.
      
      As the switch type is board-specific, and cannot be determined
      automatically, it is obtained from the presence of one of the
      "rohm,rstbmode-*" properties in DT.
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: NLee Jones <lee.jones@linaro.org>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      6eb0bfae
  5. 23 4月, 2018 2 次提交
  6. 20 4月, 2018 2 次提交
  7. 18 4月, 2018 1 次提交
  8. 17 4月, 2018 2 次提交
  9. 16 4月, 2018 1 次提交
  10. 28 3月, 2018 1 次提交
  11. 22 3月, 2018 2 次提交
  12. 20 3月, 2018 1 次提交
  13. 15 3月, 2018 1 次提交
  14. 09 3月, 2018 1 次提交
  15. 20 2月, 2018 1 次提交
    • G
      regulator: Fix resume from suspend to idle · 35b5f14e
      Geert Uytterhoeven 提交于
      When resuming from idle with the new suspend mode configuration support
      we go through the resume callbacks with a state of PM_SUSPEND_TO_IDLE
      which we don't have regulator constraints for, causing an error:
      
          dpm_run_callback(): regulator_resume_early+0x0/0x64 returns -22
          PM: Device regulator.0 failed to resume early: error -22
      
      Avoid this and similar errors by treating missing constraints as a noop.
      
      See also commit 57a0dd18 ("regulator: Fix suspend to idle"),
      which fixed the suspend part.
      Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
      Signed-off-by: NMark Brown <broonie@kernel.org>
      35b5f14e
  16. 17 2月, 2018 3 次提交
  17. 12 2月, 2018 1 次提交
  18. 08 2月, 2018 1 次提交
  19. 30 1月, 2018 1 次提交
  20. 27 1月, 2018 1 次提交
  21. 26 1月, 2018 6 次提交