sunxi: When we've both mmc0 and mmc2, detect from which one we're booting

sunxi SOCs can boot from both mmc0 and mmc2, detect from which one we're
booting, and make that one "mmc dev 0" so that a single u-boot binary can
be used for both the onboard eMMC and for external sdcards.

When we're booting from mmc2, we make it dev 0 because that is where the SPL
will load the tertiary payload (the actual u-boot binary in our case) from,
see: common/spl/spl_mmc.c, which has dev 0 hardcoded everywhere.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
sunxi: Use PG3 - PG8 as io-pins for mmc1

None of the known sunxi devices actually use mmc1 routed through PH, where
as some devices do actually use mmc1 routed through PG, so change the routing
of mmc1 to PG. If in the future we encounter devices with mmc1 routed through
PH, we will need to change things to be a bit more flexible.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
sunxi: Enable second sdcard slot found on some boards

Enable the second sdcard slot found on some boards. Note that we do not
set CONFIG_MMC_SUNXI_SLOT_EXTRA for the SPL, as having it there is not useful,

Except for on the Mele-M3 where the second sdcard is an eMMC, from which the
device can also boot, and there we want to have both in the SPL, so that
a single u-boot binary can both from both. So for the M3 we do prefix the
defconfig setting with the special "+S:" syntax so that it applies to the
SPL too.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
sunxi: Kconfig: Unify sunxi Kconfig code

Unify the sunxi Kconfig code, instead of having separate code blocks for
each of sun4i - sun7i.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Acked-by: Ian Campbell <ijc@hellion.org.uk>
kconfig: Fix compiler warning in menu.c

This fixes the following compiler warning:

In file included from scripts/kconfig/zconf.tab.c:2537:0:
scripts/kconfig/menu.c: In function ‘get_symbol_str’:
scripts/kconfig/menu.c:590:18: warning: ‘jump’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     jump->offset = strlen(r->s);
                  ^
In file included from scripts/kconfig/zconf.tab.c:2537:0:
scripts/kconfig/menu.c:551:19: note: ‘jump’ was declared here
  struct jump_key *jump;

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
video: add cfb console driver for sunxi

This adds a fixed mode hdmi driver for the sunxi platform. The fixed
mode is a relatively safe 1024x768, more complete EDID handling is
currently not provided as that would mean a significant rewrite of uboot
infrastructure. Only HDMI is supported today, DT based LCD will have to
wait until a KMS driver is out.

This code is enabled when HPD detects an attached monitor, which works
well on even A13, where no HDMI signals are externally available on the
package.

Current config is such that 8MB is shaved off at the top of the RAM.
This avoids several memory handling issues, most significant is the fact
that on linux on ARM you are not allowed to remap known RAM as IO. A
clued in display driver will be able to recycle this reserved RAM in
future though.

cfbconsole was chosen as it provides the most important functionality: a
working u-boot console, allowing for the debugging of certain issues
without the need for a UART. To enable the console on HDMI, add the
following to your boot script:
	setenv stdout serial,vga
	setenv stderr serial,vga
This will sadly only take effect after the environment is read in, which
makes this hdmi console driver less universally useful as hoped.

Signed-off-by: Luc Verhaegen <libv@skynet.be>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi:video: add simplefb support

Signed-off-by: Luc Verhaegen <libv@skynet.be>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi:video: claim clocks for simplefb

This allows an updated simplefb driver in the kernel to correctly claim
clocks, so that these do not get automatically disabled by the kernels
clock framework, and so that simplefb actually does something useful for
the kernel on sunxi hw as well.

Currently, only clocks already defined in the dt today are handled. When
a sunxi KMS driver for mainline kernel happens, further clocks will have
to get defined in the sunxi dtses, and more clocks will have to be
claimed from this side as well. It is relatively pointless to try to
claim these clocks today already, as they will most likely be
significantly altered again when KMS happens.

Signed-off-by: Luc Verhaegen <libv@skynet.be>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: Kconfig: Add CONFIG_VIDEO option to enable HDMI console support

And make this default to Y since most boards have a HDMI output.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: display: Fix clock-output-names check failure on sun5i

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: display: Add a 1920x1080 mode

Make it easy to use / test 1920x1080 by flipping a single #if.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: display: Pass around calculated clk_div and clk_double values

Rather then reading them back from the register later.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: display: 16 is not a valid clk_div value

We can use div as a clk_div for the lcdc clk, but not for the hdmi clk, so
don't try to use a clk_div of 16.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: display: Use linux-sunxi 3.4 driver values for tx clk and driver values

I don't know where the value currently in the u-boot sunxi-display driver
come from. But they cause my monitor to not sync at all with 1024x768. Use the
proven to work on many monitors values from the linux-sunxi 3.4 driver instead.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: display: Add sun5i fifo tweak from linux-sunxi 3.4 kernels

This fixes some modes / board combinations giving artifacts due to fifo
underruns.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: Remove unnecessary portnr lookup from usb_new_device

If the device has a parent, it is instantiated from usb_hub_port_connect_change
and the portnr is right there in dev->portnr, so there is no need for this
whole dance to look it up.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: Do not power-cycle usb devices on init

Do as the Linux kernel does and power on any ports which are not yet one,
this is enough.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: ehci: Do not disable an already disabled periodic schedule

When periodic_schedules == 0, the schedule is disabled and there is no reason
to disable it again.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: ehci: Move interrupt packet length check to create_int_queue

Preperation patch to use create_int_queue outside of ehci-hcd.c .

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
usb: ehci: Move cache invalidation to poll_int_queue

Preperation patch to use poll_int_queue outside of ehci-hcd.c .

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