diff mbox

[U-Boot,v4,2/2] sunxi: video: Add simplefb support

Message ID 1416239334-29802-3-git-send-email-hdegoede@redhat.com
State Superseded
Delegated to: Ian Campbell
Headers show

Commit Message

Hans de Goede Nov. 17, 2014, 3:48 p.m. UTC
From: Luc Verhaegen <libv@skynet.be>

Add simplefb support, note this depends on the kernel having support for
the clocks property which has recently been added to the simplefb devicetree
binding.

Signed-off-by: Luc Verhaegen <libv@skynet.be>
[hdegoede@redhat.com: Use pre-populated simplefb node under /chosen as
 disussed on the devicetree list]
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
 arch/arm/include/asm/arch-sunxi/display.h |  4 ++++
 board/sunxi/board.c                       | 11 +++++++++
 drivers/video/sunxi_display.c             | 39 +++++++++++++++++++++++++++++++
 include/configs/sunxi-common.h            |  8 +++++++
 4 files changed, 62 insertions(+)

Comments

Simon Glass Nov. 17, 2014, 6:39 p.m. UTC | #1
Hi Hans,

On 17 November 2014 15:48, Hans de Goede <hdegoede@redhat.com> wrote:
> From: Luc Verhaegen <libv@skynet.be>
>
> Add simplefb support, note this depends on the kernel having support for
> the clocks property which has recently been added to the simplefb devicetree
> binding.
>
> Signed-off-by: Luc Verhaegen <libv@skynet.be>
> [hdegoede@redhat.com: Use pre-populated simplefb node under /chosen as
>  disussed on the devicetree list]
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
> ---
>  arch/arm/include/asm/arch-sunxi/display.h |  4 ++++
>  board/sunxi/board.c                       | 11 +++++++++
>  drivers/video/sunxi_display.c             | 39 +++++++++++++++++++++++++++++++
>  include/configs/sunxi-common.h            |  8 +++++++
>  4 files changed, 62 insertions(+)
>
> diff --git a/arch/arm/include/asm/arch-sunxi/display.h b/arch/arm/include/asm/arch-sunxi/display.h
> index 8d80ceb..4c694f8 100644
> --- a/arch/arm/include/asm/arch-sunxi/display.h
> +++ b/arch/arm/include/asm/arch-sunxi/display.h
> @@ -195,4 +195,8 @@ struct sunxi_hdmi_reg {
>  #define SUNXI_HDMI_PLL_DBG0_PLL3               (0 << 21)
>  #define SUNXI_HDMI_PLL_DBG0_PLL7               (1 << 21)
>
> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
> +void sunxi_simplefb_setup(void *blob);
> +#endif
> +
>  #endif /* _SUNXI_DISPLAY_H */
> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
> index e6ec5b8..d4530e8 100644
> --- a/board/sunxi/board.c
> +++ b/board/sunxi/board.c
> @@ -24,6 +24,7 @@
>  #endif
>  #include <asm/arch/clock.h>
>  #include <asm/arch/cpu.h>
> +#include <asm/arch/display.h>
>  #include <asm/arch/dram.h>
>  #include <asm/arch/gpio.h>
>  #include <asm/arch/mmc.h>
> @@ -237,3 +238,13 @@ int misc_init_r(void)
>         return 0;
>  }
>  #endif
> +
> +#ifdef CONFIG_OF_BOARD_SETUP
> +void
> +ft_board_setup(void *blob, bd_t *bd)
> +{
> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
> +       sunxi_simplefb_setup(blob);
> +#endif
> +}
> +#endif /* CONFIG_OF_BOARD_SETUP */
> diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c
> index 3f46c31..74c4bd3 100644
> --- a/drivers/video/sunxi_display.c
> +++ b/drivers/video/sunxi_display.c
> @@ -13,6 +13,8 @@
>  #include <asm/arch/display.h>
>  #include <asm/global_data.h>
>  #include <asm/io.h>
> +#include <fdtdec.h>
> +#include <fdt_support.h>
>  #include <linux/fb.h>
>  #include <video_fb.h>
>
> @@ -416,3 +418,40 @@ video_hw_init(void)
>
>         return graphic_device;
>  }
> +
> +/*
> + * Simplefb support.
> + */
> +#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
> +void
> +sunxi_simplefb_setup(void *blob)
> +{
> +       static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
> +       int offset, ret;
> +
> +       if (!sunxi_display.enabled)
> +               return;

return -ENOENT?

> +
> +       /* Find a framebuffer node, with pipeline == "de_be0-lcd0-hdmi" */
> +       offset = fdt_node_offset_by_compatible(blob, -1, "sunxi,framebuffer");

These should convert to DM at some point. To make sure we don't forget
any, you should add this compatible string to fdtdec.c and use the
enum from fdtdec.h and also fdtdec_next_compatible().

> +       while (offset >= 0) {
> +               ret = fdt_find_string(blob, offset, "sunxi,pipeline",
> +                                     "de_be0-lcd0-hdmi");
> +               if (ret == 0)
> +                       break;
> +               offset = fdt_node_offset_by_compatible(blob, offset,
> +                                                      "sunxi,framebuffer");
> +       }
> +       if (offset < 0) {
> +               eprintf("Cannot setup simplefb: node not found\n");
> +               return;

return -ENODEV?

> +       }
> +
> +       ret = fdt_setup_simplefb_node(blob, offset, gd->fb_base,
> +                       graphic_device->winSizeX, graphic_device->winSizeY,
> +                       graphic_device->winSizeX * graphic_device->gdfBytesPP,
> +                       "x8r8g8b8");
> +       if (ret < 0)
> +               eprintf("Cannot setup simplefb: Error setting properties\n");

Can we return the error here? Maybe -EPERM or something like that.

> +}
> +#endif /* CONFIG_OF_BOARD_SETUP && CONFIG_VIDEO_DT_SIMPLEFB */
> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
> index 900ef52..d5d907b 100644
> --- a/include/configs/sunxi-common.h
> +++ b/include/configs/sunxi-common.h
> @@ -204,6 +204,9 @@
>   */
>  #define CONFIG_SUNXI_FB_SIZE (8 << 20)
>
> +/* Do we want to initialize a simple FB? */
> +#define CONFIG_VIDEO_DT_SIMPLEFB
> +
>  #define CONFIG_VIDEO_SUNXI
>
>  #define CONFIG_CFB_CONSOLE
> @@ -217,6 +220,11 @@
>
>  #define CONFIG_SYS_MEM_TOP_HIDE ((CONFIG_SUNXI_FB_SIZE + 0xFFF) & ~0xFFF)
>
> +/* To be able to hook simplefb into dt */
> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
> +#define CONFIG_OF_BOARD_SETUP
> +#endif
> +
>  #endif /* CONFIG_VIDEO */
>
>  /* Ethernet support */
> --
> 2.1.0
>

Regards,
Simon
Ian Campbell Nov. 17, 2014, 7:12 p.m. UTC | #2
On Mon, 2014-11-17 at 16:48 +0100, Hans de Goede wrote:
> From: Luc Verhaegen <libv@skynet.be>
> 
> Add simplefb support, note this depends on the kernel having support for
> the clocks property which has recently been added to the simplefb devicetree
> binding.
> 
> Signed-off-by: Luc Verhaegen <libv@skynet.be>
> [hdegoede@redhat.com: Use pre-populated simplefb node under /chosen as
>  disussed on the devicetree list]
> Signed-off-by: Hans de Goede <hdegoede@redhat.com>

I've no comments over and above what Simon said.

Ian.
Hans de Goede Nov. 18, 2014, 11:23 a.m. UTC | #3
Hi,

On 11/17/2014 07:39 PM, Simon Glass wrote:
> Hi Hans,
> 
> On 17 November 2014 15:48, Hans de Goede <hdegoede@redhat.com> wrote:
>> From: Luc Verhaegen <libv@skynet.be>
>>
>> Add simplefb support, note this depends on the kernel having support for
>> the clocks property which has recently been added to the simplefb devicetree
>> binding.
>>
>> Signed-off-by: Luc Verhaegen <libv@skynet.be>
>> [hdegoede@redhat.com: Use pre-populated simplefb node under /chosen as
>>  disussed on the devicetree list]
>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>> ---
>>  arch/arm/include/asm/arch-sunxi/display.h |  4 ++++
>>  board/sunxi/board.c                       | 11 +++++++++
>>  drivers/video/sunxi_display.c             | 39 +++++++++++++++++++++++++++++++
>>  include/configs/sunxi-common.h            |  8 +++++++
>>  4 files changed, 62 insertions(+)
>>
>> diff --git a/arch/arm/include/asm/arch-sunxi/display.h b/arch/arm/include/asm/arch-sunxi/display.h
>> index 8d80ceb..4c694f8 100644
>> --- a/arch/arm/include/asm/arch-sunxi/display.h
>> +++ b/arch/arm/include/asm/arch-sunxi/display.h
>> @@ -195,4 +195,8 @@ struct sunxi_hdmi_reg {
>>  #define SUNXI_HDMI_PLL_DBG0_PLL3               (0 << 21)
>>  #define SUNXI_HDMI_PLL_DBG0_PLL7               (1 << 21)
>>
>> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
>> +void sunxi_simplefb_setup(void *blob);
>> +#endif
>> +
>>  #endif /* _SUNXI_DISPLAY_H */
>> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
>> index e6ec5b8..d4530e8 100644
>> --- a/board/sunxi/board.c
>> +++ b/board/sunxi/board.c
>> @@ -24,6 +24,7 @@
>>  #endif
>>  #include <asm/arch/clock.h>
>>  #include <asm/arch/cpu.h>
>> +#include <asm/arch/display.h>
>>  #include <asm/arch/dram.h>
>>  #include <asm/arch/gpio.h>
>>  #include <asm/arch/mmc.h>
>> @@ -237,3 +238,13 @@ int misc_init_r(void)
>>         return 0;
>>  }
>>  #endif
>> +
>> +#ifdef CONFIG_OF_BOARD_SETUP
>> +void
>> +ft_board_setup(void *blob, bd_t *bd)
>> +{
>> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
>> +       sunxi_simplefb_setup(blob);
>> +#endif
>> +}
>> +#endif /* CONFIG_OF_BOARD_SETUP */
>> diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c
>> index 3f46c31..74c4bd3 100644
>> --- a/drivers/video/sunxi_display.c
>> +++ b/drivers/video/sunxi_display.c
>> @@ -13,6 +13,8 @@
>>  #include <asm/arch/display.h>
>>  #include <asm/global_data.h>
>>  #include <asm/io.h>
>> +#include <fdtdec.h>
>> +#include <fdt_support.h>
>>  #include <linux/fb.h>
>>  #include <video_fb.h>
>>
>> @@ -416,3 +418,40 @@ video_hw_init(void)
>>
>>         return graphic_device;
>>  }
>> +
>> +/*
>> + * Simplefb support.
>> + */
>> +#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
>> +void
>> +sunxi_simplefb_setup(void *blob)
>> +{
>> +       static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
>> +       int offset, ret;
>> +
>> +       if (!sunxi_display.enabled)
>> +               return;
> 
> return -ENOENT?

If people want this, I can change the proto to an int and make sunxi_simplefb_setup
return error codes as you suggest, but this function gets called from
ft_board_setup which is void itself, so there is no where to propagate the error,
and more-over we do not want simplefb setup errors to be treated as fatal, so
I see little use in having it return error codes.

>> +
>> +       /* Find a framebuffer node, with pipeline == "de_be0-lcd0-hdmi" */
>> +       offset = fdt_node_offset_by_compatible(blob, -1, "sunxi,framebuffer");
> 
> These should convert to DM at some point. To make sure we don't forget
> any, you should add this compatible string to fdtdec.c and use the
> enum from fdtdec.h and also fdtdec_next_compatible().

Most sunxi boards do not set CONFIG_OF_CONTROL, so the ftddec functions are
not available.

>> +       while (offset >= 0) {
>> +               ret = fdt_find_string(blob, offset, "sunxi,pipeline",
>> +                                     "de_be0-lcd0-hdmi");
>> +               if (ret == 0)
>> +                       break;
>> +               offset = fdt_node_offset_by_compatible(blob, offset,
>> +                                                      "sunxi,framebuffer");
>> +       }
>> +       if (offset < 0) {
>> +               eprintf("Cannot setup simplefb: node not found\n");
>> +               return;
> 
> return -ENODEV?
> 
>> +       }
>> +
>> +       ret = fdt_setup_simplefb_node(blob, offset, gd->fb_base,
>> +                       graphic_device->winSizeX, graphic_device->winSizeY,
>> +                       graphic_device->winSizeX * graphic_device->gdfBytesPP,
>> +                       "x8r8g8b8");
>> +       if (ret < 0)
>> +               eprintf("Cannot setup simplefb: Error setting properties\n");
> 
> Can we return the error here? Maybe -EPERM or something like that.
> 
>> +}
>> +#endif /* CONFIG_OF_BOARD_SETUP && CONFIG_VIDEO_DT_SIMPLEFB */
>> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
>> index 900ef52..d5d907b 100644
>> --- a/include/configs/sunxi-common.h
>> +++ b/include/configs/sunxi-common.h
>> @@ -204,6 +204,9 @@
>>   */
>>  #define CONFIG_SUNXI_FB_SIZE (8 << 20)
>>
>> +/* Do we want to initialize a simple FB? */
>> +#define CONFIG_VIDEO_DT_SIMPLEFB
>> +
>>  #define CONFIG_VIDEO_SUNXI
>>
>>  #define CONFIG_CFB_CONSOLE
>> @@ -217,6 +220,11 @@
>>
>>  #define CONFIG_SYS_MEM_TOP_HIDE ((CONFIG_SUNXI_FB_SIZE + 0xFFF) & ~0xFFF)
>>
>> +/* To be able to hook simplefb into dt */
>> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
>> +#define CONFIG_OF_BOARD_SETUP
>> +#endif
>> +
>>  #endif /* CONFIG_VIDEO */
>>
>>  /* Ethernet support */

Regards,

Hans
Simon Glass Nov. 18, 2014, 2:32 p.m. UTC | #4
Hi Hans,


On 18 November 2014 11:23, Hans de Goede <hdegoede@redhat.com> wrote:
> Hi,
>
> On 11/17/2014 07:39 PM, Simon Glass wrote:
>> Hi Hans,
>>
>> On 17 November 2014 15:48, Hans de Goede <hdegoede@redhat.com> wrote:
>>> From: Luc Verhaegen <libv@skynet.be>
>>>
>>> Add simplefb support, note this depends on the kernel having support for
>>> the clocks property which has recently been added to the simplefb devicetree
>>> binding.
>>>
>>> Signed-off-by: Luc Verhaegen <libv@skynet.be>
>>> [hdegoede@redhat.com: Use pre-populated simplefb node under /chosen as
>>>  disussed on the devicetree list]
>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>> ---
>>>  arch/arm/include/asm/arch-sunxi/display.h |  4 ++++
>>>  board/sunxi/board.c                       | 11 +++++++++
>>>  drivers/video/sunxi_display.c             | 39 +++++++++++++++++++++++++++++++
>>>  include/configs/sunxi-common.h            |  8 +++++++
>>>  4 files changed, 62 insertions(+)
>>>
>>> diff --git a/arch/arm/include/asm/arch-sunxi/display.h b/arch/arm/include/asm/arch-sunxi/display.h
>>> index 8d80ceb..4c694f8 100644
>>> --- a/arch/arm/include/asm/arch-sunxi/display.h
>>> +++ b/arch/arm/include/asm/arch-sunxi/display.h
>>> @@ -195,4 +195,8 @@ struct sunxi_hdmi_reg {
>>>  #define SUNXI_HDMI_PLL_DBG0_PLL3               (0 << 21)
>>>  #define SUNXI_HDMI_PLL_DBG0_PLL7               (1 << 21)
>>>
>>> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
>>> +void sunxi_simplefb_setup(void *blob);
>>> +#endif
>>> +
>>>  #endif /* _SUNXI_DISPLAY_H */
>>> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
>>> index e6ec5b8..d4530e8 100644
>>> --- a/board/sunxi/board.c
>>> +++ b/board/sunxi/board.c
>>> @@ -24,6 +24,7 @@
>>>  #endif
>>>  #include <asm/arch/clock.h>
>>>  #include <asm/arch/cpu.h>
>>> +#include <asm/arch/display.h>
>>>  #include <asm/arch/dram.h>
>>>  #include <asm/arch/gpio.h>
>>>  #include <asm/arch/mmc.h>
>>> @@ -237,3 +238,13 @@ int misc_init_r(void)
>>>         return 0;
>>>  }
>>>  #endif
>>> +
>>> +#ifdef CONFIG_OF_BOARD_SETUP
>>> +void
>>> +ft_board_setup(void *blob, bd_t *bd)
>>> +{
>>> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
>>> +       sunxi_simplefb_setup(blob);
>>> +#endif
>>> +}
>>> +#endif /* CONFIG_OF_BOARD_SETUP */
>>> diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c
>>> index 3f46c31..74c4bd3 100644
>>> --- a/drivers/video/sunxi_display.c
>>> +++ b/drivers/video/sunxi_display.c
>>> @@ -13,6 +13,8 @@
>>>  #include <asm/arch/display.h>
>>>  #include <asm/global_data.h>
>>>  #include <asm/io.h>
>>> +#include <fdtdec.h>
>>> +#include <fdt_support.h>
>>>  #include <linux/fb.h>
>>>  #include <video_fb.h>
>>>
>>> @@ -416,3 +418,40 @@ video_hw_init(void)
>>>
>>>         return graphic_device;
>>>  }
>>> +
>>> +/*
>>> + * Simplefb support.
>>> + */
>>> +#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
>>> +void
>>> +sunxi_simplefb_setup(void *blob)
>>> +{
>>> +       static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
>>> +       int offset, ret;
>>> +
>>> +       if (!sunxi_display.enabled)
>>> +               return;
>>
>> return -ENOENT?
>
> If people want this, I can change the proto to an int and make sunxi_simplefb_setup
> return error codes as you suggest, but this function gets called from
> ft_board_setup which is void itself, so there is no where to propagate the error,
> and more-over we do not want simplefb setup errors to be treated as fatal, so
> I see little use in having it return error codes.

ft_board_setup() will soon change to return an error. Will likely
merge those patches next week.

>
>>> +
>>> +       /* Find a framebuffer node, with pipeline == "de_be0-lcd0-hdmi" */
>>> +       offset = fdt_node_offset_by_compatible(blob, -1, "sunxi,framebuffer");
>>
>> These should convert to DM at some point. To make sure we don't forget
>> any, you should add this compatible string to fdtdec.c and use the
>> enum from fdtdec.h and also fdtdec_next_compatible().
>
> Most sunxi boards do not set CONFIG_OF_CONTROL, so the ftddec functions are
> not available.

Actually I was wrong - this is adjust the kernel FDT so ignore my comment.

>
>>> +       while (offset >= 0) {
>>> +               ret = fdt_find_string(blob, offset, "sunxi,pipeline",
>>> +                                     "de_be0-lcd0-hdmi");
>>> +               if (ret == 0)
>>> +                       break;
>>> +               offset = fdt_node_offset_by_compatible(blob, offset,
>>> +                                                      "sunxi,framebuffer");
>>> +       }
>>> +       if (offset < 0) {
>>> +               eprintf("Cannot setup simplefb: node not found\n");
>>> +               return;
>>
>> return -ENODEV?
>>
>>> +       }
>>> +
>>> +       ret = fdt_setup_simplefb_node(blob, offset, gd->fb_base,
>>> +                       graphic_device->winSizeX, graphic_device->winSizeY,
>>> +                       graphic_device->winSizeX * graphic_device->gdfBytesPP,
>>> +                       "x8r8g8b8");
>>> +       if (ret < 0)
>>> +               eprintf("Cannot setup simplefb: Error setting properties\n");
>>
>> Can we return the error here? Maybe -EPERM or something like that.
>>
>>> +}
>>> +#endif /* CONFIG_OF_BOARD_SETUP && CONFIG_VIDEO_DT_SIMPLEFB */
>>> diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
>>> index 900ef52..d5d907b 100644
>>> --- a/include/configs/sunxi-common.h
>>> +++ b/include/configs/sunxi-common.h
>>> @@ -204,6 +204,9 @@
>>>   */
>>>  #define CONFIG_SUNXI_FB_SIZE (8 << 20)
>>>
>>> +/* Do we want to initialize a simple FB? */
>>> +#define CONFIG_VIDEO_DT_SIMPLEFB
>>> +
>>>  #define CONFIG_VIDEO_SUNXI
>>>
>>>  #define CONFIG_CFB_CONSOLE
>>> @@ -217,6 +220,11 @@
>>>
>>>  #define CONFIG_SYS_MEM_TOP_HIDE ((CONFIG_SUNXI_FB_SIZE + 0xFFF) & ~0xFFF)
>>>
>>> +/* To be able to hook simplefb into dt */
>>> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
>>> +#define CONFIG_OF_BOARD_SETUP
>>> +#endif
>>> +
>>>  #endif /* CONFIG_VIDEO */
>>>
>>>  /* Ethernet support */

Regards,
Simon
Hans de Goede Nov. 18, 2014, 2:54 p.m. UTC | #5
Hi,

On 11/18/2014 03:32 PM, Simon Glass wrote:
> Hi Hans,
> 
> 
> On 18 November 2014 11:23, Hans de Goede <hdegoede@redhat.com> wrote:
>> Hi,
>>
>> On 11/17/2014 07:39 PM, Simon Glass wrote:
>>> Hi Hans,
>>>
>>> On 17 November 2014 15:48, Hans de Goede <hdegoede@redhat.com> wrote:
>>>> From: Luc Verhaegen <libv@skynet.be>
>>>>
>>>> Add simplefb support, note this depends on the kernel having support for
>>>> the clocks property which has recently been added to the simplefb devicetree
>>>> binding.
>>>>
>>>> Signed-off-by: Luc Verhaegen <libv@skynet.be>
>>>> [hdegoede@redhat.com: Use pre-populated simplefb node under /chosen as
>>>>  disussed on the devicetree list]
>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>>> ---
>>>>  arch/arm/include/asm/arch-sunxi/display.h |  4 ++++
>>>>  board/sunxi/board.c                       | 11 +++++++++
>>>>  drivers/video/sunxi_display.c             | 39 +++++++++++++++++++++++++++++++
>>>>  include/configs/sunxi-common.h            |  8 +++++++
>>>>  4 files changed, 62 insertions(+)
>>>>
>>>> diff --git a/arch/arm/include/asm/arch-sunxi/display.h b/arch/arm/include/asm/arch-sunxi/display.h
>>>> index 8d80ceb..4c694f8 100644
>>>> --- a/arch/arm/include/asm/arch-sunxi/display.h
>>>> +++ b/arch/arm/include/asm/arch-sunxi/display.h
>>>> @@ -195,4 +195,8 @@ struct sunxi_hdmi_reg {
>>>>  #define SUNXI_HDMI_PLL_DBG0_PLL3               (0 << 21)
>>>>  #define SUNXI_HDMI_PLL_DBG0_PLL7               (1 << 21)
>>>>
>>>> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
>>>> +void sunxi_simplefb_setup(void *blob);
>>>> +#endif
>>>> +
>>>>  #endif /* _SUNXI_DISPLAY_H */
>>>> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
>>>> index e6ec5b8..d4530e8 100644
>>>> --- a/board/sunxi/board.c
>>>> +++ b/board/sunxi/board.c
>>>> @@ -24,6 +24,7 @@
>>>>  #endif
>>>>  #include <asm/arch/clock.h>
>>>>  #include <asm/arch/cpu.h>
>>>> +#include <asm/arch/display.h>
>>>>  #include <asm/arch/dram.h>
>>>>  #include <asm/arch/gpio.h>
>>>>  #include <asm/arch/mmc.h>
>>>> @@ -237,3 +238,13 @@ int misc_init_r(void)
>>>>         return 0;
>>>>  }
>>>>  #endif
>>>> +
>>>> +#ifdef CONFIG_OF_BOARD_SETUP
>>>> +void
>>>> +ft_board_setup(void *blob, bd_t *bd)
>>>> +{
>>>> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
>>>> +       sunxi_simplefb_setup(blob);
>>>> +#endif
>>>> +}
>>>> +#endif /* CONFIG_OF_BOARD_SETUP */
>>>> diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c
>>>> index 3f46c31..74c4bd3 100644
>>>> --- a/drivers/video/sunxi_display.c
>>>> +++ b/drivers/video/sunxi_display.c
>>>> @@ -13,6 +13,8 @@
>>>>  #include <asm/arch/display.h>
>>>>  #include <asm/global_data.h>
>>>>  #include <asm/io.h>
>>>> +#include <fdtdec.h>
>>>> +#include <fdt_support.h>
>>>>  #include <linux/fb.h>
>>>>  #include <video_fb.h>
>>>>
>>>> @@ -416,3 +418,40 @@ video_hw_init(void)
>>>>
>>>>         return graphic_device;
>>>>  }
>>>> +
>>>> +/*
>>>> + * Simplefb support.
>>>> + */
>>>> +#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
>>>> +void
>>>> +sunxi_simplefb_setup(void *blob)
>>>> +{
>>>> +       static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
>>>> +       int offset, ret;
>>>> +
>>>> +       if (!sunxi_display.enabled)
>>>> +               return;
>>>
>>> return -ENOENT?
>>
>> If people want this, I can change the proto to an int and make sunxi_simplefb_setup
>> return error codes as you suggest, but this function gets called from
>> ft_board_setup which is void itself, so there is no where to propagate the error,
>> and more-over we do not want simplefb setup errors to be treated as fatal, so
>> I see little use in having it return error codes.
> 
> ft_board_setup() will soon change to return an error. Will likely
> merge those patches next week.

That is good to hear, but not relevant in this case, as said:

"more-over we do not want simplefb setup errors to be treated as fatal"

Main reason for this is that older dtb-s do not have the pre-populated
simplefb node. I guess it could be argued that not having the node
should be a warning (and return 0), and the other errors should be
real errors. I can be convinced to make that change, let me know either
way.

Regards,

Hans
Simon Glass Nov. 18, 2014, 3:08 p.m. UTC | #6
Hi Hans,


On 18 November 2014 14:54, Hans de Goede <hdegoede@redhat.com> wrote:
> Hi,
>
> On 11/18/2014 03:32 PM, Simon Glass wrote:
>> Hi Hans,
>>
>>
>> On 18 November 2014 11:23, Hans de Goede <hdegoede@redhat.com> wrote:
>>> Hi,
>>>
>>> On 11/17/2014 07:39 PM, Simon Glass wrote:
>>>> Hi Hans,
>>>>
>>>> On 17 November 2014 15:48, Hans de Goede <hdegoede@redhat.com> wrote:
>>>>> From: Luc Verhaegen <libv@skynet.be>
>>>>>
>>>>> Add simplefb support, note this depends on the kernel having support for
>>>>> the clocks property which has recently been added to the simplefb devicetree
>>>>> binding.
>>>>>
>>>>> Signed-off-by: Luc Verhaegen <libv@skynet.be>
>>>>> [hdegoede@redhat.com: Use pre-populated simplefb node under /chosen as
>>>>>  disussed on the devicetree list]
>>>>> Signed-off-by: Hans de Goede <hdegoede@redhat.com>
>>>>> ---
>>>>>  arch/arm/include/asm/arch-sunxi/display.h |  4 ++++
>>>>>  board/sunxi/board.c                       | 11 +++++++++
>>>>>  drivers/video/sunxi_display.c             | 39 +++++++++++++++++++++++++++++++
>>>>>  include/configs/sunxi-common.h            |  8 +++++++
>>>>>  4 files changed, 62 insertions(+)
>>>>>
>>>>> diff --git a/arch/arm/include/asm/arch-sunxi/display.h b/arch/arm/include/asm/arch-sunxi/display.h
>>>>> index 8d80ceb..4c694f8 100644
>>>>> --- a/arch/arm/include/asm/arch-sunxi/display.h
>>>>> +++ b/arch/arm/include/asm/arch-sunxi/display.h
>>>>> @@ -195,4 +195,8 @@ struct sunxi_hdmi_reg {
>>>>>  #define SUNXI_HDMI_PLL_DBG0_PLL3               (0 << 21)
>>>>>  #define SUNXI_HDMI_PLL_DBG0_PLL7               (1 << 21)
>>>>>
>>>>> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
>>>>> +void sunxi_simplefb_setup(void *blob);
>>>>> +#endif
>>>>> +
>>>>>  #endif /* _SUNXI_DISPLAY_H */
>>>>> diff --git a/board/sunxi/board.c b/board/sunxi/board.c
>>>>> index e6ec5b8..d4530e8 100644
>>>>> --- a/board/sunxi/board.c
>>>>> +++ b/board/sunxi/board.c
>>>>> @@ -24,6 +24,7 @@
>>>>>  #endif
>>>>>  #include <asm/arch/clock.h>
>>>>>  #include <asm/arch/cpu.h>
>>>>> +#include <asm/arch/display.h>
>>>>>  #include <asm/arch/dram.h>
>>>>>  #include <asm/arch/gpio.h>
>>>>>  #include <asm/arch/mmc.h>
>>>>> @@ -237,3 +238,13 @@ int misc_init_r(void)
>>>>>         return 0;
>>>>>  }
>>>>>  #endif
>>>>> +
>>>>> +#ifdef CONFIG_OF_BOARD_SETUP
>>>>> +void
>>>>> +ft_board_setup(void *blob, bd_t *bd)
>>>>> +{
>>>>> +#ifdef CONFIG_VIDEO_DT_SIMPLEFB
>>>>> +       sunxi_simplefb_setup(blob);
>>>>> +#endif
>>>>> +}
>>>>> +#endif /* CONFIG_OF_BOARD_SETUP */
>>>>> diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c
>>>>> index 3f46c31..74c4bd3 100644
>>>>> --- a/drivers/video/sunxi_display.c
>>>>> +++ b/drivers/video/sunxi_display.c
>>>>> @@ -13,6 +13,8 @@
>>>>>  #include <asm/arch/display.h>
>>>>>  #include <asm/global_data.h>
>>>>>  #include <asm/io.h>
>>>>> +#include <fdtdec.h>
>>>>> +#include <fdt_support.h>
>>>>>  #include <linux/fb.h>
>>>>>  #include <video_fb.h>
>>>>>
>>>>> @@ -416,3 +418,40 @@ video_hw_init(void)
>>>>>
>>>>>         return graphic_device;
>>>>>  }
>>>>> +
>>>>> +/*
>>>>> + * Simplefb support.
>>>>> + */
>>>>> +#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
>>>>> +void
>>>>> +sunxi_simplefb_setup(void *blob)
>>>>> +{
>>>>> +       static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
>>>>> +       int offset, ret;
>>>>> +
>>>>> +       if (!sunxi_display.enabled)
>>>>> +               return;
>>>>
>>>> return -ENOENT?
>>>
>>> If people want this, I can change the proto to an int and make sunxi_simplefb_setup
>>> return error codes as you suggest, but this function gets called from
>>> ft_board_setup which is void itself, so there is no where to propagate the error,
>>> and more-over we do not want simplefb setup errors to be treated as fatal, so
>>> I see little use in having it return error codes.
>>
>> ft_board_setup() will soon change to return an error. Will likely
>> merge those patches next week.
>
> That is good to hear, but not relevant in this case, as said:
>
> "more-over we do not want simplefb setup errors to be treated as fatal"
>
> Main reason for this is that older dtb-s do not have the pre-populated
> simplefb node. I guess it could be argued that not having the node
> should be a warning (and return 0), and the other errors should be
> real errors. I can be convinced to make that change, let me know either
> way.

Yes that sounds right to me.

Regards,
Simon
diff mbox

Patch

diff --git a/arch/arm/include/asm/arch-sunxi/display.h b/arch/arm/include/asm/arch-sunxi/display.h
index 8d80ceb..4c694f8 100644
--- a/arch/arm/include/asm/arch-sunxi/display.h
+++ b/arch/arm/include/asm/arch-sunxi/display.h
@@ -195,4 +195,8 @@  struct sunxi_hdmi_reg {
 #define SUNXI_HDMI_PLL_DBG0_PLL3		(0 << 21)
 #define SUNXI_HDMI_PLL_DBG0_PLL7		(1 << 21)
 
+#ifdef CONFIG_VIDEO_DT_SIMPLEFB
+void sunxi_simplefb_setup(void *blob);
+#endif
+
 #endif /* _SUNXI_DISPLAY_H */
diff --git a/board/sunxi/board.c b/board/sunxi/board.c
index e6ec5b8..d4530e8 100644
--- a/board/sunxi/board.c
+++ b/board/sunxi/board.c
@@ -24,6 +24,7 @@ 
 #endif
 #include <asm/arch/clock.h>
 #include <asm/arch/cpu.h>
+#include <asm/arch/display.h>
 #include <asm/arch/dram.h>
 #include <asm/arch/gpio.h>
 #include <asm/arch/mmc.h>
@@ -237,3 +238,13 @@  int misc_init_r(void)
 	return 0;
 }
 #endif
+
+#ifdef CONFIG_OF_BOARD_SETUP
+void
+ft_board_setup(void *blob, bd_t *bd)
+{
+#ifdef CONFIG_VIDEO_DT_SIMPLEFB
+	sunxi_simplefb_setup(blob);
+#endif
+}
+#endif /* CONFIG_OF_BOARD_SETUP */
diff --git a/drivers/video/sunxi_display.c b/drivers/video/sunxi_display.c
index 3f46c31..74c4bd3 100644
--- a/drivers/video/sunxi_display.c
+++ b/drivers/video/sunxi_display.c
@@ -13,6 +13,8 @@ 
 #include <asm/arch/display.h>
 #include <asm/global_data.h>
 #include <asm/io.h>
+#include <fdtdec.h>
+#include <fdt_support.h>
 #include <linux/fb.h>
 #include <video_fb.h>
 
@@ -416,3 +418,40 @@  video_hw_init(void)
 
 	return graphic_device;
 }
+
+/*
+ * Simplefb support.
+ */
+#if defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_VIDEO_DT_SIMPLEFB)
+void
+sunxi_simplefb_setup(void *blob)
+{
+	static GraphicDevice *graphic_device = &sunxi_display.graphic_device;
+	int offset, ret;
+
+	if (!sunxi_display.enabled)
+		return;
+
+	/* Find a framebuffer node, with pipeline == "de_be0-lcd0-hdmi" */
+	offset = fdt_node_offset_by_compatible(blob, -1, "sunxi,framebuffer");
+	while (offset >= 0) {
+		ret = fdt_find_string(blob, offset, "sunxi,pipeline",
+				      "de_be0-lcd0-hdmi");
+		if (ret == 0)
+			break;
+		offset = fdt_node_offset_by_compatible(blob, offset,
+						       "sunxi,framebuffer");
+	}
+	if (offset < 0) {
+		eprintf("Cannot setup simplefb: node not found\n");
+		return;
+	}
+
+	ret = fdt_setup_simplefb_node(blob, offset, gd->fb_base,
+			graphic_device->winSizeX, graphic_device->winSizeY,
+			graphic_device->winSizeX * graphic_device->gdfBytesPP,
+			"x8r8g8b8");
+	if (ret < 0)
+		eprintf("Cannot setup simplefb: Error setting properties\n");
+}
+#endif /* CONFIG_OF_BOARD_SETUP && CONFIG_VIDEO_DT_SIMPLEFB */
diff --git a/include/configs/sunxi-common.h b/include/configs/sunxi-common.h
index 900ef52..d5d907b 100644
--- a/include/configs/sunxi-common.h
+++ b/include/configs/sunxi-common.h
@@ -204,6 +204,9 @@ 
  */
 #define CONFIG_SUNXI_FB_SIZE (8 << 20)
 
+/* Do we want to initialize a simple FB? */
+#define CONFIG_VIDEO_DT_SIMPLEFB
+
 #define CONFIG_VIDEO_SUNXI
 
 #define CONFIG_CFB_CONSOLE
@@ -217,6 +220,11 @@ 
 
 #define CONFIG_SYS_MEM_TOP_HIDE ((CONFIG_SUNXI_FB_SIZE + 0xFFF) & ~0xFFF)
 
+/* To be able to hook simplefb into dt */
+#ifdef CONFIG_VIDEO_DT_SIMPLEFB
+#define CONFIG_OF_BOARD_SETUP
+#endif
+
 #endif /* CONFIG_VIDEO */
 
 /* Ethernet support */