xtensa: simplify addition of new core variants

Instead of adding new Kconfig options and Makefile rules for each new
core variant provide XTENSA_VARIANT_CUSTOM variant and record variant
name in the XTENSA_VARIANT_NAME variable. Adding new core variant now
means providing directory structure under arch/xtensa/variant and
specifying correct name in kernel configuration.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: make MMU-related configuration options depend on MMU

MMUv3 and HIGHMEM support are available only on configurations with MMU,
don't show them otherwise.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: sort 'select' statements in Kconfig

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: select HAVE_IDE only on platforms that may have it

HAVE_IDE is not a property of architecture but of a platform, and neither
ISS or XTFPGA support it.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: remove orphan MATH_EMULATION symbol

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: replace IOCTL code definitions with constants

This fixes userspace code that builds on other architectures but fails
on xtensa due to references to structures that other architectures don't
refer to. E.g. this fixes the following issue with python-2.7.8:

  python-2.7.8/Modules/termios.c:861:25: error: invalid application
     of 'sizeof' to incomplete type 'struct serial_multiport_struct'
     {"TIOCSERGETMULTI", TIOCSERGETMULTI},
  python-2.7.8/Modules/termios.c:870:25: error: invalid application
     of 'sizeof' to incomplete type 'struct serial_multiport_struct'
     {"TIOCSERSETMULTI", TIOCSERSETMULTI},
  python-2.7.8/Modules/termios.c:900:24: error: invalid application
     of 'sizeof' to incomplete type 'struct tty_struct'
     {"TIOCTTYGSTRUCT", TIOCTTYGSTRUCT},

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: fix address checks in dma_{alloc,free}_coherent

Virtual address is translated to the XCHAL_KSEG_CACHED region in the
dma_free_coherent, but is checked to be in the 0...XCHAL_KSEG_SIZE
range.

Change check for end of the range from 'addr >= X' to 'addr > X - 1' to
handle the case of X == 0.

Replace 'if (C) BUG();' construct with 'BUG_ON(C);'.

Cc: stable@vger.kernel.org
Signed-off-by: Alan Douglas <adouglas@cadence.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: add renameat2 syscall

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
Cc: Chris Zankel <chris@zankel.net>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: fix access to THREAD_RA/THREAD_SP/THREAD_DS

With SMP and a lot of debug options enabled task_struct::thread gets out
of reach of s32i/l32i instructions with base pointing at task_struct,
breaking build with the following messages:

  arch/xtensa/kernel/entry.S: Assembler messages:
  arch/xtensa/kernel/entry.S:1002: Error: operand 3 of 'l32i.n' has invalid value '1048'
  arch/xtensa/kernel/entry.S:1831: Error: operand 3 of 's32i.n' has invalid value '1040'
  arch/xtensa/kernel/entry.S:1832: Error: operand 3 of 's32i.n' has invalid value '1044'

Change base to point to task_struct::thread in such cases.
Don't use a10 in _switch_to to save/restore prev pointer as a2 is not
clobbered.

Cc: stable@vger.kernel.org
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
WIP: xtensa: xtfpga: disable lcd

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
WIP: xtensa: xtfpga: add CY7C67300 USB controller support

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: update FSF variant

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: add test_kc705 variant

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: add Three Core HiFi-2 MX Variant.

This variant is equipped with MX and is capable of running SMP linux.

Signed-off-by: Piet Delaney <piet.delaney@gmail.com>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: add test_kc705_ca variant

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: add test_kc705_hifi variant

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: add shabu variant

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: add test_kc705_be variant

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Merge branches 'xtensa-cores', 'xtensa-fixes' and 'xtensa-kc705' into xtensa-staging
xtensa: fix kernel/user jump out of fast_unaligned

Use correct register (a0, just read from the PS) to check user mode bit.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>