sun6i: s/SUNXI_GPL0_R_P2WI/SUN6I_GPL0_R_P2WI/

The p2wi interface is only available on sun6i, adjust the gpio pinmux defines
for it to reflect this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: Add support for the rsb (Reduced Serial Bus)

sun8i (A23) introduces a new bus for communicating with the pmic, the rsb,
the rsb is also used to communicate with the pmic on the A80, and is
documented in the A80 user manual.

This commit adds support for this based on the rsb driver from the allwinner
u-boot sources.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: axp221: Add axp223 support

The axp223 appears to be the same as the axp221, except that it uses the
rsb to communicate rather then the p2wi. At least all the registers we use
are 100% the same.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: axp221: Add Kconfig help and sane defaults for typical ldo usage

Some of the ldo-s of the axp221 are used in the same way on most boards, add
comments to the Kconfig help text to reflect this, and give them defaults
matching their typical usage.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: axp221: Make dcdc1 voltage configurable

The dcdc1 voltage is typically used as generic 3.3V IO voltage for things like
GPIO-s, sdcard interfaces, etc. On most boards this is undervolted to 3.0V to
safe battery, but not on all, make it configurable so that we can use the
same settings as the original firmware on all boards.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: axp221: Explicitly turn off unused voltages

Explicitly turn off unused voltages, rather then leaving them as is. Likewise
explictly enabled the dcdc convertors, rather then assuming they are already
enabled at boot.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: axp221: Disable dcdc4 on sun8i (A23)

dcdc4 is not used on sun8i, disable it.

While at it also add comments to the other fixed voltages to document what
they are used for.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sun6i: Add a sigma_delta_enable paramter to clock_set_pll5()

The sun8i dram code sometimes wants to enable sigma delta mode,
add a parameter to allow this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sun6i: Add k and m parameters to clock_set_pll5()

The A23 (sun8i) requires different values for these then sun6i, so make them
function parameters.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: Move await_completion dram helper to dram.h

The await_completion helper is already copy pasted between the sun4i and sun6i
dram code, and we need it for sun8i too, so lets make it an inline helper in
dram.h, rather then adding yet another copy.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: Fill memory before comparing it when doing dram init on sun6i

The sun8i boot0 code fills the DRAM with a "random" pattern before comparing
it at different offsets to do columns, etc. detection. The sun6i boot0 code
does not do it, but it seems like a good idea to do this regardless.

The new mctl_mem_fill function this introduces is added as an inline helper
in dram.h, so that it can be shared with the sun8i dram code.

While at it move mctl_mem_matches to dram.h for re-use in sun8i too.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: Use memcmp for mctl_mem_matches

Use memcmp for mctl_mem_matches instead of DIY.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sun8i: Add dram initialization support

Based on the register / dram_para headers from the Allwinner u-boot / linux
sources + the init sequences from boot0.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sun8i: Add defconfig for Ippo_q8h v1.2

We need separate defconfigs for the v5 and v1.2 versions of this board, as
they use different DRAM parameters.

Note they also use different dtb files, as the wifi is different too.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
videomodes: Add pixelclock_khz and refresh fields to ctfb_res_modes

Add pixelclock_khz and refresh fields to ctfb_res_modes:

1) pixelclocks are usually referred to in hz, not picoseconds, and e.g
pll-s are also typically programmed in hz, not ps. Converting between the
2 leads to rounding differences, add a pixelclock_khz field to directly
store the *exact* pixelclock for a mode, so that drivers do not need to
resort to rounding tricks to try and guess the exact pixelclock;

2) The video-mode environment variable, as parsed by video_get_video_mode
also contains the vertical refresh rate, add a refresh field, so that
the refresh-rate can be matched when parsing the video-mode environment
variable.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
videomodes: Add (vesa) standard timings

The timings for the modes defined in videomodes.c differ (significantly)
from vesa standard timings for these modes.

This commit adds a version with the proper std timings for these modes,
since I do not want to cause regressions, boards which want to use the standard
timings need to define CONFIG_VIDEO_STD_TIMINGS to get the new correct timings.

Since there is no std timing for 960x720 this commit uses the timing used
by the nvidia video drivers for 960x720, which uses a standard pixelclock
of 74.25 MHz rather then the weird 76.335... clock used by the old modes.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
videomodes: Add a bunch of high res modes

Add modes useful for hd-tvs and modern monitors.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
videomodes: Add video_get_ctfb_res_modes helper function

Add a video_get_ctfb_res_modes() helper function, which uses
video_get_video_mode() to parse the 'video-mode' environment variable and then
looks up the matching mode in res_mode_init and returns the matching mode.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
videomodes: Add helper functions to parse video-mode env-var extra options

Add 2 helper functions to get strings, reps. ints from the options value
returned by video_get_video_mode() / video_get_ctfb_res_modes().

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
videomodes: Add video_edid_dtd_to_ctfb_res_modes helper function

Add a video_edid_dtd_to_ctfb_res_modes helper function to convert an EDID
detailed timing to a struct ctfb_res_modes.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>