mbox series

[0/2] regulator: of: add device tree property for allowed modes

Message ID cover.1526088289.git.collinsd@codeaurora.org
Headers show
Series regulator: of: add device tree property for allowed modes | expand

Message

David Collins May 12, 2018, 1:46 a.m. UTC
There is currently no accepted way to configure constraints->valid_modes_mask
for regulators defined in device tree.  This patch series defines a new
common regulator device tree property, regulator-allowed-modes, which can be
used to specify the set of modes that the regulator is allowed to use.
It also implements parsing for this new property inside of the
of_get_regulation_constraints() function.

David Collins (2):
  regulator: of: add property for allowed modes specification
  regulator: of: add support for allowed modes configuration

 .../devicetree/bindings/regulator/regulator.txt    |  5 ++++
 drivers/regulator/of_regulator.c                   | 29 +++++++++++++++++++++-
 2 files changed, 33 insertions(+), 1 deletion(-)

Comments

Doug Anderson May 17, 2018, 9:22 p.m. UTC | #1
Hi,

On Fri, May 11, 2018 at 6:46 PM, David Collins <collinsd@codeaurora.org> wrote:
> @@ -136,6 +136,33 @@ static void of_get_regulation_constraints(struct device_node *np,
>                 }
>         }
>
> +       len = of_property_count_elems_of_size(np, "regulator-allowed-modes",
> +                                               sizeof(u32));
> +       if (len > 0) {
> +               if (desc && desc->of_map_mode) {
> +                       for (i = 0; i < len; i++) {
> +                               ret = of_property_read_u32_index(np,
> +                                       "regulator-allowed-modes", i, &pval);
> +                               if (ret) {
> +                                       pr_err("%s: couldn't read allowed modes index %d, ret=%d\n",
> +                                               np->name, i, ret);
> +                                       break;
> +                               }
> +                               mode = desc->of_map_mode(pval);
> +                               if (mode == REGULATOR_MODE_INVALID)
> +                                       pr_err("%s: invalid regulator-allowed-modes element %u\n",
> +                                               np->name, pval);
> +                               else
> +                                       constraints->valid_modes_mask |= mode;
> +                       }
> +                       if (constraints->valid_modes_mask)
> +                               constraints->valid_ops_mask
> +                                       |= REGULATOR_CHANGE_MODE;

Kinda calls into question the value of REGULATOR_CHANGE_MODE in the
valid_ops_mask if it's just set whenever valid_modes_mask is non-zero,
huh?

> +               } else {
> +                       pr_warn("%s: mode mapping not defined\n", np->name);
> +               }
> +       }
> +

This patch seems good to me.

Reviewed-by: Douglas Anderson <dianders@chromium.org>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html