sunxi-sound: Fix soc-audio.x should use snd_soc_register_card() warnings

These warnings are thrown at runtime when the device(s) in question are
registering.

Note this is possibly a 3.4 only thing / patch-series.

While almost rewriting this code anyways also fix:
1) script_parser_fetch's last argument is an integer count, not a byte count
2) Fix cleaning up of platform_device when driver registration fails
3) On module onload properly remove both the device and the driver

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-sound: Move registration of hdmi-audio devices to sunxi-hdmi code

Registering the hdmi audio-devices when not using hdmi means that userspace
may end up trying to use hdmi while it is not working. When hdmi-audio is
not enabled, and userspace still tries to use it the audio-using app(s) will
hang when trying to write to the audio-device, since the write will never
complete when the video-part is not consuming any hdmi-audio.

Note that this patch does not unregister the audio-card again if the hdmi
block is powered down (dpms / blank screen), so as to avoid audio-streaming
apps to crash / abort because the soundcard has gone away. Instead the app
will pause (write will block) on monitor powerdown and resume again when
the monitor powers back on.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-sound: Cleanup spdif_used parsing

Various spdif_used parsing fixes / cleanups:
1) sun4i_spdma was not honoring spdif_used
2) There are 4 .ko files build for spdif, having each of them complain when
   spdif_used is not set is a bit too much
3) script_parser_fetch's last argument is an integer count, not a byte count
4) Fix cleaning up of platform_device when driver registration fails
5) On module onload properly remove both the device and the driver

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-sound: Honor audio_used fex file setting

So that devices which don't have analog audio hooked up don't get an
alsa sound-card for it.

While almost rewriting this code anyways also fix:
1) Cleaning up of platform_device when driver registration fails
2) On module onload properly remove both the device and the driver

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-sound: Honor capture_used and playback_used

So that the onboard-coded alsa-card does not advertises that it can playback /
capture sound on boards which cannot.

Note playback_used is a linux-sunxi.org fex file extension for boards which use
the onboard audio codec only for input, such as the uhost_u1a & mk802-a10s.

Since playback_used is a linux-sunxi.org fex file extension, it is assumed to
be 1 when not set.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi-rfkill: Don't register a bluetooth rfkill device when there is no bt

This also modifies mmc_pm_get_mod_type to make it safe to call before the
mmc_pm module_init function has completed running, since the sunxi-rfkill
module_init function may run first.

Signed-off-by: Hans de Goede <hdegoede@redhat.com>
sunxi: disambiguate sw_get_ic_ver()'s enum

Signed-off-by: Alejandro Mery <amery@geeks.cl>
sunxi: soc-detect: move sw_get_ic_ver() to a separated module

Signed-off-by: Alejandro Mery <amery@geeks.cl>
sunxi:soc-detect: move sunxi_chip_id() out of core.c

Signed-off-by: Alejandro Mery <amery@geeks.cl>
sunxi: don't assume SUNXI_VER_A10A == 0

Signed-off-by: Alejandro Mery <amery@geeks.cl>
sunxi: extend sw_get_ic_ver() to detect sun5i chips

based on Allwinner's mach-sun5i code to "magically" detect the chip

Signed-off-by: Alejandro Mery <amery@geeks.cl>
sunxi:soc-detect: print detected SoC the first time
sunxi: add sunxi_is_${soc_name}() macros

supporting all known sun4i and sun5i SoCs.
- sunxi_is_a10()
- sunxi_is_a13()
- sunxi_is_a12()
- sunxi_is_a10s()

Signed-off-by: Alejandro Mery <amery@geeks.cl>
sunxi: implement sw_get_chip_id()

from latest sun[45]i SDK

Signed-off-by: Alejandro Mery <amery@geeks.cl>
SUN5I GPIO EINT definition and fix to irq search function

This patch fix the break condition in "sunxi_find_gpio_irq" to prevent the early stop of the search in the "gpio_eint_list".
If the EINT enumeration is discontinuous it could happen that some elements in the list are empty, but the search must go on until the scan of the list is complete, without stopping at the first not-defined EINT.
For example, as defined in "gpio-sunxi.h" patch, SUN5I arch has only some of the 32 interrupts available, but the enumeration is not continuous. This is not a problem in the SUN4I which has all the 0-31 interrupts defined.

EINT_NUM definition in "gpio-sunxi.h" is 32 because there are 4 8-bit registers for interrupts configuration, so it should be reasonable that the interrupt layout of SUN5I is simlar to SUN4I with only some irqs enable.

Signed-off-by: Lorenzo Nava <lorenx4@gmail.com>
sunxi:soc-detect: mark sw_get_ic_ver() as pure

Signed-off-by: Alejandro Mery <amery@geeks.cl>
sunxi:soc-detect: fix typos on sunxi_is_*() macros

Signed-off-by: Alejandro Mery <amery@geeks.cl>
gpio:sunxi: move eint table within the .c and using sunxi_is_foo()

Signed-off-by: Alejandro Mery <amery@geeks.cl>
sunxi: bring sunxi_pr_chip_id() back, but using the ic_ver

Signed-off-by: Alejandro Mery <amery@geeks.cl>
sunxi:soc-detect: rename sunxi_chip_id() to sunxi_brom_chip_id()

because there are other methods

Signed-off-by: Alejandro Mery <amery@geeks.cl>