sun4i_defconfig: build disp, hdmi and lcd into the kernel

- The majority of end-users wants to use the framebuffer, and all other options are aimed at that (e.g. G2D, Cedar,
  framebuffer memory reservation are all enabled by default)
- Previous problems that required building these options as modules instead of into the kernel no longer exist
  (since this commit: https://github.com/linux-sunxi/linux-sunxi/commit/199825c44a742fa0abd274948c5f66535b614fb7 )
sunxi-disp: Allow build without axp

I wrote this patch while working on A10s support, then when I tried to
get my Olinuxino A13_Micro running using commits from
https://github.com/hehopmajieh/linux-sunxi/

I noticed a similar patch there:
https://github.com/hehopmajieh/linux-sunxi/commit/e7c1fc23a723bdf799c0aef02920b55650c06e12

But I believe this fix is better because:
1) It properly checks for CONFIG_AXP rather then CONFIG_POWER, as the former
can still be unset when the latter is set
2) Rather then just ignoring axp gpio calls when not build with axp support
it complains loudly when other code tries to use axp gpio-s when built without

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-disp: Don't crash on sun5i when screen0_output_type == vga

I was (wrongly) trying to set screen0_output_type to vga for the
Olinuxino A13_Micro (the Olinuxino A13 * uses LCD output + some external
logic for VGA-out).

This leads to a NULL ref due to the sunxi-disp-vga code containing some
special handling for composite out which tries to set up dac parameters
on the 2nd tv-encoder. *But* the sun5i only has 1 tv-encoder.

Even though this was mainly caused by a wrong fex file I'm still submitting
this patch, because the A10s does have a fully functional display block,
which likely does support VGA out.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-disp: Fix page alignment issues with UMP buffers

UMP buffers must be page aligned, otherwise we get a problem:

[   80.520000] UMP: ERR: drivers/gpu/mali/ump/common/ump_kernel_ref_drv.c
[   80.530000]            ump_dd_handle_create_from_phys_blocks()  50
[   80.530000] Trying to create UMP memory with unaligned size. Size: 5760000
[   80.540000]
[   80.540000] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[   80.550000] pgd = ee09c000
[   80.560000] [00000000] *pgd=00000000
[   80.560000] Internal error: Oops: 5 [#1] PREEMPT ARM
[   80.560000] Modules linked in: disp_ump mali_drm drm mali ump 8192cu hdmi lcd disp cfbcopyarea cfbimgblt cfbfillrect
[   80.560000] CPU: 0    Not tainted  (3.4.24+ #30)
[   80.560000] PC is at ump_dd_secure_id_get+0xc/0x14 [ump]
[   80.560000] LR is at _disp_get_ump_secure_id+0x5c/0xec [disp_ump]
[   80.560000] pc : [<bf116c4c>]    lr : [<bf19905c>]    psr: 600f0013
[   80.560000] sp : ee4efd78  ip : ee4efd88  fp : ee4efd84
[   80.560000] r10: be8f9c4c  r9 : 00000000  r8 : bf03a4c4
[   80.560000] r7 : 00000001  r6 : bf03a4c4  r5 : 5a001000  r4 : eeb81000
[   80.560000] r3 : 00000000  r2 : 200f0093  r1 : 00000001  r0 : 00000000
[   80.560000] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
[   80.560000] Control: 10c5387d  Table: 6e09c019  DAC: 00000015

The code, which tries to split the framebuffer into two parts of equal
sizes for GET_UMP_SECURE_ID_BUF1 and GET_UMP_SECURE_ID_BUF2, may break
this assumption for certain screen resolutions (800x600 is particularly
poorly divisible by 4096). The user visible symptoms look like the X
server gets stuck and fails to start.

This patch addresses the problem in the following way:
1. Make sure that fix.smem_len is page aligned (like many of the
   other framebuffer drivers do).
2. If the splitting of framebuffer into two parts would result in
   unaligned second part, just disable double buffering.
3. Avoid wrapping the physical memory beyond the framebuffer
   for GET_UMP_SECURE_ID_BUF2 in the case if double buffering
   is not used by setting the size of UMP buffer to 0.

The problem has been reported at:
  https://groups.google.com/d/msg/linux-sunxi/kZNl9bFdE-g/4k8z2_i4nJgJ

Signed-off-by: Siarhei Siamashka <siarhei.siamashka@gmail.com>
sunxi-hdmi: Refactor EDID parsing

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-hdmi: Add pixelclock override table to edid code

Unfortunately some monitors need pixelclocks which we cannot generate,
often we can workaround this by selecting a pixelclock which is near the
requested pixelclock. This patch adds a table with modes + overriding /
corrected pixelclock, and adds a first entry for the 1680x1050 mode of
Samsung 225bw monitors.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
input:touchscreen:ft5x_ts: Change MT events per Android 4.0 requirements
sunxi-disp: Fb_check_var: only check hdmi clock for enabled selections

Currently using vga output can fail, when the other selection output-type is
set to hdmi, because Fb_check_var will check the hdmi clock for any selection
which has its output set to hdmi, even if that selection is not enabled.

This patch fixes this.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Jari Helaakoski <tekkuli@gmail.com>
Add AXP 15 power module for A10s Chips

HdG: Note as usual with code imported from the sunxi SDK there are severe
style issues :|

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
axp15: Hookup the axp152 code

HdG: Fixed some checkpatch warnings

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
axp15: Adjust code for 3.4 branch

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
mach-sun5i: Remove bogus debug-uart device

I encountered this while testing my A10s TV-stick, which uses uart0 for
its uart test-pads.

Having this device always registered + uart0_used set in the fex file,
caused 2 uart driver to get registered for uart0, both the regular
serial8250 as well as the 8250-sunxi driver, then when the first uart0
interrupt happens things go boom.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Platform code function rename to resolve gpiolib conflict

Signed-off-by: Alexandr V. Shutko <alex@shutko.ru>
Allow pin read in output mode

Signed-off-by: Alexandr V. Shutko <alex@shutko.ru>
sunxi: move clocksource code to plat-sunxi

It is identical for sun4i and sun5i, so no merging was needed.

Note checkpatch very much dislikes the code, but this patch does not change it,
it just moves it around.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: Merge/move core.c code from mach to plat

Note that:
1) This patch also includes one functionaly change, the clock_event_device
declared in core.c had a rating of 100 in sun4i and of 300 for sun5i. This
patch keeps the sun4i setting, thereby working around the timer0 code being
broken in periodic mode (something to fix another day), as the working
"highres" clock_event_device from clocksrc.c has a rating of 300 and thus
gets used instead *if* CONFIG_HIGH_RES_TIMERS is set!

This subtle change fixes the sun5i_defconfig kernel hanging within 10 - 30
seconds after boot due to the timer stopping.

2) checkpatch dislikes parts of this patch, but this patch is just moving
(ugly) code around not introducing it.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: Add sunxi_*_mem_reserve kernel cmdline options

This patch adds the following kernel commandline options:
sunxi_g2d_mem_reserve
sunxi_ve_mem_reserve
sunxi_fb_mem_reserve

These can be set to configure the amount of RAM (in MB) to reserve for the
named sunxi drivers. This is useful for kernels for ready-to-use disk images,
so that an user can choose to use various binary only drivers to use the
hardware blocks in question, while not making the memory unavailable for
general use for users who choose not to use these drivers, without requiring
a kernel recompile.

IE I'm currently using the following since I don't use any binary drivers:
sunxi_g2d_mem_reserve=0 sunxi_ve_mem_reserve=0 sunxi_fb_mem_reserve=16

Giving me an additional 112 MB of extra memory.

Note that:
1) This patch also allows making the reservations larger in an easy way :)
2) This patch removes the comments stating that memory won't be reserved if
the block in question is disabled in the fex file, since this was not true
before this patch, and still is not true after this patch.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: Also allow disabling MALI mem reservation from the cmdline

This patch adds a new "sunxi_no_mali_mem_reserve" kernel commandline options
to disable the memory reservation for the mali driver, makign the 64MB of
RAM in question usable for other purposes.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-disp: Fall back to kmalloc-ed mem when no fb mem is reserved

Since it is now possible to disable fb-mem reservation from the cmdline,
enable the kmalloc fallback path even if CONFIG_FB_SUNXI_RESERVED_MEM is set.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
axp20: Don't create the virtual axp devs if pmu_used is not set

This stops dmesg showing these:
[   86.720000] platform reg-20-cs-buck3: Driver reg-20-cs-buck3 requests probe deferral
[   86.720000] platform reg-20-cs-buck2: Driver reg-20-cs-buck2 requests probe deferral
[   86.740000] platform reg-20-cs-ldo4: Driver reg-20-cs-ldo4 requests probe def
<snip more of the same>

Each time a usb device gets (un)plugged when using a generic kernel build
(so with axp20 enabled) on a board without a pmu, such as the mk802, or
the a13_olinuxino_micro.

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