[U-Boot] [PATCH] fdt: add new fdt_fixup_display function to configure display

Simon Glass sjg at chromium.org
Wed Apr 8 03:50:31 CEST 2015


Hi Tim,

On 6 April 2015 at 08:07, Tim Harvey <tharvey at gateworks.com> wrote:
>
> Add 'fdt_fixup_display' function to fixup device-tree for a specific
> display. This is useful if a device-tree has configurations for multiple
> display timings for undetectable displays.
>
> Signed-off-by: Tim Harvey <tharvey at gateworks.com>
> ---
>  common/fdt_support.c  | 31 +++++++++++++++++++++++++++++++
>  include/fdt_support.h |  1 +
>  2 files changed, 32 insertions(+)
>
> diff --git a/common/fdt_support.c b/common/fdt_support.c
> index 8266bca..60609e5 100644
> --- a/common/fdt_support.c
> +++ b/common/fdt_support.c
> @@ -1560,3 +1560,34 @@ int fdt_setup_simplefb_node(void *fdt, int node, u64 base_address, u32 width,
>
>         return 0;
>  }
> +
> +/*
> + * Update native-mode in display-timings from display environment variable.
> + * The node to update are specified by path.
> + */
> +int fdt_fixup_display(void *blob, const char *path, const char *display)
> +{
> +       int off, toff;
> +
> +       if (!display || !path)
> +               return -1;

This is -FDT_ERR_NOTFOUND. Better to be explicit.

> +
> +       toff = fdt_path_offset(blob, path);
> +       if (toff >= 0)
> +               toff = fdt_subnode_offset(blob, toff, "display-timings");
> +       if (toff < 0)
> +               return toff;
> +
> +       for (off = fdt_first_subnode(blob, toff);
> +            off >= 0;
> +            off = fdt_next_subnode(blob, off)) {
> +               uint32_t handle = fdt_get_phandle(blob, off);
> +               debug("%s:0x%x\n", fdt_get_name(blob, off, NULL),
> +                     fdt32_to_cpu(handle));
> +               if (strcasecmp(fdt_get_name(blob, off, NULL), display) == 0) {
> +                       fdt_setprop_u32(blob, toff, "native-mode", handle);

Error checking.

> +                       break;
> +               }
> +       }
> +       return toff;
> +}
> diff --git a/include/fdt_support.h b/include/fdt_support.h
> index ae5e8a3..98379d3 100644
> --- a/include/fdt_support.h
> +++ b/include/fdt_support.h
> @@ -46,6 +46,7 @@ void fdt_fixup_ethernet(void *fdt);
>  int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
>                          const void *val, int len, int create);
>  void fdt_fixup_qe_firmware(void *fdt);
> +int fdt_fixup_display(void *blob, const char *path, const char *display);

Function comment for this please - see ft_board_setup() as an example.
Remember to document the return value.

>
>  #if defined(CONFIG_HAS_FSL_DR_USB) || defined(CONFIG_HAS_FSL_MPH_USB)
>  void fdt_fixup_dr_usb(void *blob, bd_t *bd);
> --
> 1.9.1
>

Regards,
Simon


More information about the U-Boot mailing list