videomodes: Add support for refresh and pclk_khz to video_get_params()

Add support to video_get_params() for setting the new refresh and pixclock_khz
struct ctfb_res_modes members.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
sunxi: gpio: Properly sort mux defines by port number

Move a few mux defines around so that all the mux defines are properly sorted
by port number.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
sunxi: gpio: Add support for gpio pins on the AXP209 pmic

Some boards use GPIO-s on the pmic, one example of this is the A13-OLinuXino
board, which uses gpio0 of the axp209 for the lcd-power signal.

This commit adds support for gpio pins on the AXP209 pmic, the sunxi_gpio.c
changes are universal, adding gpio support for the other AXP pmics (when
necessary) should be a matter of adding the necessary axp_gpio_foo functions
to their resp. drivers, and add "#define AXP_GPIO" to their header file.

Note this commit only adds support for the non device-model version of the
gpio code, patches for adding support to the device-model version are very
welcome.

The string representation for these gpio-s is AXP0-#, the 0 in the AXP0 prefix
is there in case we need to support gpio-s on more then 1 pmic in the future.
At least A80 boards have 2 pmics, and we may end up needing to support gpio-s
on both.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Remove duplicate defines for AXP209_GPIO_OUTPUT_LOW / HIGH
-Add & improve some comments
sunxi: video: Drop disabling of backend / lcdc / hdmi encoder on modeset

The enable flags are initialized to 0 already by engines_init, so now that
we no longer retry the mode-set, the disabling of the blocks in
sunxi_mode_set() is a no-op.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
sunxi: video: Improve monitor video-mode option handling

Add a sunxi_monitor enum and parse the monitor option string into this enum
once, rather then doing strcmp-s on it in various places. This also adds
checking for it being a valid value.

This also adds new "none" and "lcd" values in preparation for lcd support.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Add a sunxi_get_mon_desc helper to convert from the monitor enum to strings
sunxi: video: Prepare for lcd support

Refactor sunxi_mode_set into a bunch of helpers, and make it do a switch
case on sunxi_display.monitor to decide what to do.

Also rename sunxi_lcdc_mode_set to sunxi_lcdc_tcon1_mode_set, as it sets the
timings for tcon1, and for lcd support we need a similar function operating
on tcon0.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
sunxi: video: Modify sunxi_lcdc_pll_set to work with both tcon0 and tcon1

Modify sunxi_lcdc_pll_set to work with both tcon0 and tcon1, this is a
preparation patch for adding lcd support.

While at it also swap the divider search order, searching from low to
high, as the comment above the code says we should do. In cases where there
are multiple solutions this will result in picking a lower pll clock and
divider, which is more stable and saves power.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: video: Move sunxi_drc_init

Move sunxi_drc_init to directly above sunxi_engines_init, to avoid
unnecessary #ifdef-ery in later patches.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: video: Add lcd output support

Add lcd output support, see the new Kconfig entries and doc/README.video for
how to enable / configure this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: video: Add suppport SoCs without HDMI, e.g. the A13 and A23

Some SoCs, specifically the A13 (sun5i variant) and the A23 (sun8i) only have
lcd output support.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: video: Add support for VGA via external DACs connected to the LCD pins

Add support for external DACs connected to the parallel LCD interface driving
a VGA connector, such as found on the Olimex A13 boards.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: sunxi-common.h: Reduce bootm_size to take the framebuffer into account

Before video output support can be enabled on the A13-OLinuXinoM, bootm_size
must first be reduced to take into account that the framebuffer is shaved of
the top of the DRAM. For other boards this is not an issue since bootm was set
to 256M and all boards have at least 512M except for the A13-OLinuXinoM.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: A13-OLinuXino defconfigs: Enable VGA output, add lcd-mode for 7" LCD

Enable VGA output on the A13-OLinuXino and A13-OLinuXinoM now that we've
support for it.

Also add LCD timing and gpio info for the Olimex 7" LCD module. We can safely
put this in the default config on this boards, since by default we will always
use VGA, and the LCD timing info will only get used if the user explicitly
sets monitor=lcd in the video-mode env. variable.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: Add 2 defconfigs for using the Olimex 7" lcd with olinuxino boards

Add defconfigs for using the Olimex 7" lcd with the A10s-OLinuXino-M and
the A20-OLinuXino_MICRO boards.

Note this cannot be added to the regular defconfigs, like with the A13 boards,
because the video code will automatically fallback to driving the LCD if
no HDMI cable is connected (this is the desired behavior on e.g. tablets),
but the LCD connector on the Olimex dev boards may be used for something
completely different, so we do not want to automatically enable it.

Note I do not intend to add defconfigs for all possible permutation of Olimex
boards and LCD displays, these 2 serve mostly as examples. In the long run
this should be solved by moving all the LCD info into dts files and using
devicetree overlays for add-on modules like the LCD displays.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: Ippo_q8h defconfigs: Enable the LCD panel found on these tablets.

Enable the new LCD support on Ippo_q8h tablets.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: video: Remove sunxi_display.enabled variable

Having both a sunxi_display.enabled variable and
sunxi_display.monitor == sunxi_monitor_none duplicates state, use
sunxi_display.monitor = sunxi_monitor_none when ever we do not have a display.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: video: Use sunxi_lcdc_get_clk_delay to calculate tcon1 delay

Use sunxi_lcdc_get_clk_delay to calculate tcon1 delay instead of hardcoding
it to 30. We will still end up using 30 for most modes, but for e.g. 800x600
this makes a (small) difference.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: video: Fix tcon0 hsync / vsync setting

It turns out that the problems I was seeing were due to a bad powersupply,
so enable proper negative hsync / vsync support.

Also adjust various defconfigs to keep the hsync and vsync for the lcd
panels positive, changing sync:0 into sync:3.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: video: Add support for using PORTD hsync/vsync pins with tcon1

Add support for using PORTD hsync/vsync pins with tcon1, this is a preparation
patch for adding native VGA support.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: video: Fallback from HDMI to VGA on boards with VGA

If a board has no LCD, but does have VGA fallback to VGA when no HDMI cable
is connected (unless hpd=0).

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
---
Changes in v2:
-Fix missing "break;" in v1 which caused hdmi output to no longer work