[U-Boot] [PATCH v2 06/10] PINCTRL: stm32f7: add pin control driver

Simon Glass sjg at chromium.org
Sat Feb 11 20:19:26 UTC 2017


On 10 February 2017 at 16:11, Vikas Manocha <vikas.manocha at st.com> wrote:
> This driver uses the same pin control binding as that of linux, binding
> document of this patch is copied from linux. One addition done is for
> GPIO input and output mode configuration which was missing.
>
> Signed-off-by: Vikas Manocha <vikas.manocha at st.com>

Reviewed-by: Simon Glass <sjg at chromium.org>

(if you add that to the patch I don't need to remember whether I reviewed
it or not)

> ---
>
> Changed in v2:
>         - added blank lines in code like before return and after
>           variable declaration.
>         - remove not used function.
>         - changed fixed length array read from DT node to relaxed length
read.
>
>
>  configs/stm32f746-disco_defconfig                  |   3 +
>  .../pinctrl/st,stm32-pinctrl.txt                   | 133
+++++++++++++++++++++
>  drivers/pinctrl/Kconfig                            |   9 ++
>  drivers/pinctrl/Makefile                           |   1 +
>  drivers/pinctrl/pinctrl_stm32.c                    | 121
+++++++++++++++++++
>  5 files changed, 267 insertions(+)
>  create mode 100644 doc/device-tree-bindings/pinctrl/st,stm32-pinctrl.txt
>  create mode 100644 drivers/pinctrl/pinctrl_stm32.c
>
[...]

> +static int stm32_pinctrl_set_state_simple(struct udevice *dev,
> +                                         struct udevice *periph)
> +{
> +       u32 pin_mux[50];
> +       struct fdtdec_phandle_args args;
> +       int rv, len;
> +
> +       /* Get node pinctrl-0 */
> +       rv = fdtdec_parse_phandle_with_args(gd->fdt_blob,
periph->of_offset,
> +                                          "pinctrl-0", 0, 0, 0, &args);
> +       if (rv)
> +               return rv;
> +       /*
> +        * check for "pinmux" property in each subnode (e.g. pins1 and
pins2 for
> +        * usart1) of pin controller phandle "pinctrl-0"
> +        * */
> +       fdt_for_each_subnode(args.node, gd->fdt_blob, args.node) {
> +               struct stm32_gpio_dsc gpio_dsc;
> +               struct stm32_gpio_ctl gpio_ctl;
> +               int i;
> +
> +               /*
> +                * just to get the length of "pinmux" to allocate correct
size
> +                * or memory
> +                * */
> +               fdt_get_property(gd->fdt_blob, args.node, "pinmux", &len);
> +               len /= 4;
> +               debug("%s: no of pinmux entries= %d\n", __func__, len);
> +               len = fdtdec_get_int_array_count(gd->fdt_blob, args.node,
> +                                                "pinmux", pin_mux, len);

Just to be clear, instead of those 5 lines, you should be able to do:

              len = fdtdec_get_int_array_count(gd->fdt_blob, args.node,
                                               "pinmux", pin_mux,
ARRAY_SIZE(pin_mux));

> +               if (len < 0)
> +                       return -EINVAL;

[..]

Regards,
Simon


More information about the U-Boot mailing list