Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b920de1b authored by David Howells's avatar David Howells Committed by Linus Torvalds
Browse files

mn10300: add the MN10300/AM33 architecture to the kernel



Add architecture support for the MN10300/AM33 CPUs produced by MEI to the
kernel.

This patch also adds board support for the ASB2303 with the ASB2308 daughter
board, and the ASB2305.  The only processor supported is the MN103E010, which
is an AM33v2 core plus on-chip devices.

[akpm@linux-foundation.org: nuke cvs control strings]
Signed-off-by: default avatarMasakazu Urade <urade.masakazu@jp.panasonic.com>
Signed-off-by: default avatarKoichi Yasutake <yasutake.koichi@jp.panasonic.com>
Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent ef3d5347
Loading
Loading
Loading
Loading
+149 −0
Original line number Diff line number Diff line
			   =========================
			   MN10300 FUNCTION CALL ABI
			   =========================

=======
GENERAL
=======

The MN10300/AM33 kernel runs in little-endian mode; big-endian mode is not
supported.

The stack grows downwards, and should always be 32-bit aligned. There are
separate stack pointer registers for userspace and the kernel.


================
ARGUMENT PASSING
================

The first two arguments (assuming up to 32-bits per argument) to a function are
passed in the D0 and D1 registers respectively; all other arguments are passed
on the stack.

If 64-bit arguments are being passed, then they are never split between
registers and the stack. If the first argument is a 64-bit value, it will be
passed in D0:D1. If the first argument is not a 64-bit value, but the second
is, the second will be passed entirely on the stack and D1 will be unused.

Arguments smaller than 32-bits are not coelesced within a register or a stack
word. For example, two byte-sized arguments will always be passed in separate
registers or word-sized stack slots.


=================
CALLING FUNCTIONS
=================

The caller must allocate twelve bytes on the stack for the callee's use before
it inserts a CALL instruction. The CALL instruction will write into the TOS
word, but won't actually modify the stack pointer; similarly, the RET
instruction reads from the TOS word of the stack, but doesn't move the stack
pointer beyond it.


	Stack:
	|		|
	|		|
	|---------------| SP+20
	| 4th Arg	|
	|---------------| SP+16
	| 3rd Arg	|
	|---------------| SP+12
	| D1 Save Slot	|
	|---------------| SP+8
	| D0 Save Slot	|
	|---------------| SP+4
	| Return Addr	|
	|---------------| SP
	|		|
	|		|


The caller must leave space on the stack (hence an allocation of twelve bytes)
in which the callee may store the first two arguments.


============
RETURN VALUE
============

The return value is passed in D0 for an integer (or D0:D1 for a 64-bit value),
or A0 for a pointer.

If the return value is a value larger than 64-bits, or is a structure or an
array, then a hidden first argument will be passed to the callee by the caller:
this will point to a piece of memory large enough to hold the result of the
function. In this case, the callee will return the value in that piece of
memory, and no value will be returned in D0 or A0.


===================
REGISTER CLOBBERING
===================

The values in certain registers may be clobbered by the callee, and other
values must be saved:

	Clobber:	D0-D1, A0-A1, E0-E3
	Save:		D2-D3, A2-A3, E4-E7, SP

All other non-supervisor-only registers are clobberable (such as MDR, MCRL,
MCRH).


=================
SPECIAL REGISTERS
=================

Certain ordinary registers may carry special usage for the compiler:

	A3:	Frame pointer
	E2:	TLS pointer


==========
KERNEL ABI
==========

The kernel may use a slightly different ABI internally.

 (*) E2

     If CONFIG_MN10300_CURRENT_IN_E2 is defined, then the current task pointer
     will be kept in the E2 register, and that register will be marked
     unavailable for the compiler to use as a scratch register.

     Normally the kernel uses something like:

	MOV	SP,An
	AND	0xFFFFE000,An
	MOV	(An),Rm		// Rm holds current
	MOV	(yyy,Rm)	// Access current->yyy

     To find the address of current; but since this option permits current to
     be carried globally in an register, it can use:

	MOV	(yyy,E2)	// Access current->yyy

     instead.


===============
SYSTEM CALL ABI
===============

System calls are called with the following convention:

	REGISTER	ENTRY			EXIT
	===============	=======================	=======================
	D0		Syscall number		Return value
	A0		1st syscall argument	Saved
	D1		2nd syscall argument	Saved
	A3		3rd syscall argument	Saved
	A2		4th syscall argument	Saved
	D3		5th syscall argument	Saved
	D2		6th syscall argument	Saved

All other registers are saved.  The layout is a consequence of the way the MOVM
instruction stores registers onto the stack.
+60 −0
Original line number Diff line number Diff line
		   =========================================
		   PART-SPECIFIC SOURCE COMPARTMENTALISATION
		   =========================================

The sources for various parts are compartmentalised at two different levels:

 (1) Processor level

     The "processor level" is a CPU core plus the other on-silicon
     peripherals.

     Processor-specific header files are divided among directories in a similar
     way to the CPU level:

	(*) include/asm-mn10300/proc-mn103e010/

	    Support for the AM33v2 CPU core.

     The appropriate processor is selected by a CONFIG_MN10300_PROC_YYYY option
     from the "Processor support" choice menu in the arch/mn10300/Kconfig file.


 (2) Unit level

     The "unit level" is a processor plus all the external peripherals
     controlled by that processor.

     Unit-specific header files are divided among directories in a similar way
     to the CPU level; not only that, but specific sources may also be
     segregated into separate directories under the arch directory:

	(*) include/asm-mn10300/unit-asb2303/
	(*) arch/mn10300/unit-asb2303/

	    Support for the ASB2303 board with an ASB2308 daughter board.

	(*) include/asm-mn10300/unit-asb2305/
	(*) arch/mn10300/unit-asb2305/

	    Support for the ASB2305 board.

     The appropriate processor is selected by a CONFIG_MN10300_UNIT_ZZZZ option
     from the "Unit type" choice menu in the arch/mn10300/Kconfig file.


============
COMPILE TIME
============

When the kernel is compiled, symbolic links will be made in the asm header file
directory for this arch:

	include/asm-mn10300/proc => include/asm-mn10300/proc-YYYY/
	include/asm-mn10300/unit => include/asm-mn10300/unit-ZZZZ/

So that the header files contained in those directories can be accessed without
lots of #ifdef-age.

The appropriate arch/mn10300/unit-ZZZZ directory will also be entered by the
compilation process; all other unit-specific directories will be ignored.
+9 −0
Original line number Diff line number Diff line
@@ -2614,6 +2614,15 @@ L: linux-kernel@vger.kernel.org
W:	http://www.linux-mm.org
S:	Maintained

MEI MN10300/AM33 PORT
P:	David Howells
M:	dhowells@redhat.com
P:	Koichi Yasutake
M:	yasutake.koichi@jp.panasonic.com
L:	linux-am33-list@redhat.com
W:	ftp://ftp.redhat.com/pub/redhat/gnupro/AM33/
S:	Maintained

MEMORY TECHNOLOGY DEVICES (MTD)
P:	David Woodhouse
M:	dwmw2@infradead.org

arch/mn10300/Kconfig

0 → 100644
+381 −0
Original line number Diff line number Diff line
#
# For a description of the syntax of this configuration file,
# see Documentation/kbuild/kconfig-language.txt.
#

mainmenu "Linux Kernel Configuration"

config MN10300
	def_bool y

config AM33
	def_bool y

config MMU
	def_bool y

config HIGHMEM
	def_bool n

config NUMA
	def_bool n

config UID16
	def_bool y

config RWSEM_GENERIC_SPINLOCK
	def_bool y

config RWSEM_XCHGADD_ALGORITHM
	bool

config GENERIC_HARDIRQS_NO__DO_IRQ
	def_bool y

config GENERIC_CALIBRATE_DELAY
	def_bool y

config GENERIC_FIND_NEXT_BIT
	def_bool y

config GENERIC_HWEIGHT
	def_bool y

config GENERIC_TIME
	def_bool y

config GENERIC_BUG
	def_bool y

config QUICKLIST
	def_bool y

config ARCH_HAS_ILOG2_U32
	def_bool y

config ARCH_SUPPORTS_AOUT
	def_bool n

# Use the generic interrupt handling code in kernel/irq/
config GENERIC_HARDIRQS
	def_bool y

config HOTPLUG_CPU
	def_bool n

mainmenu "Matsushita MN10300/AM33 Kernel Configuration"

source "init/Kconfig"


menu "Matsushita MN10300 system setup"

choice
	prompt "Unit type"
	default MN10300_UNIT_ASB2303
	help
	  This option specifies board for which the kernel will be
	  compiled. It affects the external peripherals catered for.

config MN10300_UNIT_ASB2303
	bool "ASB2303"

config MN10300_UNIT_ASB2305
	bool "ASB2305"

endchoice

choice
	prompt "Processor support"
	default MN10300_PROC_MN103E010
	help
	  This option specifies the processor for which the kernel will be
	  compiled. It affects the on-chip peripherals catered for.

config MN10300_PROC_MN103E010
	bool "MN103E010"
	depends on MN10300_UNIT_ASB2303 || MN10300_UNIT_ASB2305
	select MN10300_PROC_HAS_TTYSM0
	select MN10300_PROC_HAS_TTYSM1
	select MN10300_PROC_HAS_TTYSM2

endchoice

choice
	prompt "Processor core support"
	default MN10300_CPU_AM33V2
	help
	  This option specifies the processor core for which the kernel will be
	  compiled. It affects the instruction set used.

config MN10300_CPU_AM33V2
	bool "AM33v2"

endchoice

config FPU
	bool "FPU present"
	default y
	depends on MN10300_PROC_MN103E010

choice
	prompt "CPU Caching mode"
	default MN10300_CACHE_WBACK
	help
	  This option determines the caching mode for the kernel.

	  Write-Back caching mode involves the all reads and writes causing
	  the affected cacheline to be read into the cache first before being
	  operated upon. Memory is not then updated by a write until the cache
	  is filled and a cacheline needs to be displaced from the cache to
	  make room. Only at that point is it written back.

	  Write-Through caching only fetches cachelines from memory on a
	  read. Writes always get written directly to memory. If the affected
	  cacheline is also in cache, it will be updated too.

	  The final option is to turn of caching entirely.

config MN10300_CACHE_WBACK
	bool "Write-Back"

config MN10300_CACHE_WTHRU
	bool "Write-Through"

config MN10300_CACHE_DISABLED
	bool "Disabled"

endchoice

menu "Memory layout options"

config KERNEL_RAM_BASE_ADDRESS
	hex "Base address of kernel RAM"
	default "0x90000000"

config INTERRUPT_VECTOR_BASE
	hex "Base address of vector table"
	default "0x90000000"
	help
	  The base address of the vector table will be programmed into
          the TBR register. It must be on 16MiB address boundary.

config KERNEL_TEXT_ADDRESS
	hex "Base address of kernel"
	default "0x90001000"

config KERNEL_ZIMAGE_BASE_ADDRESS
	hex "Base address of compressed vmlinux image"
	default "0x90700000"

endmenu

config PREEMPT
	bool "Preemptible Kernel"
	help
	  This option reduces the latency of the kernel when reacting to
	  real-time or interactive events by allowing a low priority process to
	  be preempted even if it is in kernel mode executing a system call.
	  This allows applications to run more reliably even when the system is
	  under load.

	  Say Y here if you are building a kernel for a desktop, embedded
	  or real-time system.  Say N if you are unsure.

config PREEMPT_BKL
	bool "Preempt The Big Kernel Lock"
	depends on PREEMPT
	default y
	help
	  This option reduces the latency of the kernel by making the
	  big kernel lock preemptible.

	  Say Y here if you are building a kernel for a desktop system.
	  Say N if you are unsure.

config MN10300_CURRENT_IN_E2
	bool "Hold current task address in E2 register"
	default y
	help
	  This option removes the E2/R2 register from the set available to gcc
	  for normal use and instead uses it to store the address of the
	  current process's task_struct whilst in the kernel.

	  This means the kernel doesn't need to calculate the address each time
	  "current" is used (take SP, AND with mask and dereference pointer
	  just to get the address), and instead can just use E2+offset
	  addressing each time.

	  This has no effect on userspace.

config MN10300_USING_JTAG
	bool "Using JTAG to debug kernel"
	default y
	help
	  This options indicates that JTAG will be used to debug the kernel. It
	  suppresses the use of certain hardware debugging features, such as
	  single-stepping, which are taken over completely by the JTAG unit.

config MN10300_RTC
	bool "Using MN10300 RTC"
	depends on MN10300_PROC_MN103E010
	default n
	help

	  This option enables support for the RTC, thus enabling time to be
	  tracked, even when system is powered down. This is available on-chip
	  on the MN103E010.

config MN10300_WD_TIMER
	bool "Using MN10300 watchdog timer"
	default y
	help
	  This options indicates that the watchdog timer will be used.

config PCI
	bool "Use PCI"
	depends on MN10300_UNIT_ASB2305
	default y
	help
	  Some systems (such as the ASB2305) have PCI onboard. If you have one
	  of these boards and you wish to use the PCI facilities, say Y here.

	  The PCI-HOWTO, available from
	  <http://www.tldp.org/docs.html#howto>, contains valuable
	  information about which PCI hardware does work under Linux and which
	  doesn't.

source "drivers/pci/Kconfig"

source "drivers/pcmcia/Kconfig"

menu "MN10300 internal serial options"

config MN10300_PROC_HAS_TTYSM0
	bool
	default n

config MN10300_PROC_HAS_TTYSM1
	bool
	default n

config MN10300_PROC_HAS_TTYSM2
	bool
	default n

config MN10300_TTYSM
	bool "Support for ttySM serial ports"
	depends on MN10300
	default y
	select SERIAL_CORE
	help
	  This option enables support for the on-chip serial ports that the
	  MN10300 has available.

config MN10300_TTYSM_CONSOLE
	bool "Support for console on ttySM serial ports"
	depends on MN10300_TTYSM
	select SERIAL_CORE_CONSOLE
	help
	  This option enables support for a console on the on-chip serial ports
	  that the MN10300 has available.

#
# /dev/ttySM0
#
config MN10300_TTYSM0
	bool "Enable SIF0 (/dev/ttySM0)"
	depends on MN10300_TTYSM && MN10300_PROC_HAS_TTYSM0
	help
	  Enable access to SIF0 through /dev/ttySM0 or gdb-stub

choice
	prompt "Select the timer to supply the clock for SIF0"
	default MN10300_TTYSM0_TIMER8
	depends on MN10300_TTYSM0

config MN10300_TTYSM0_TIMER8
	bool "Use timer 8 (16-bit)"

config MN10300_TTYSM0_TIMER2
	bool "Use timer 2 (8-bit)"

endchoice

#
# /dev/ttySM1
#
config MN10300_TTYSM1
	bool "Enable SIF1 (/dev/ttySM1)"
	depends on MN10300_TTYSM && MN10300_PROC_HAS_TTYSM1
	help
	  Enable access to SIF1 through /dev/ttySM1 or gdb-stub

choice
	prompt "Select the timer to supply the clock for SIF1"
	default MN10300_TTYSM0_TIMER9
	depends on MN10300_TTYSM1

config MN10300_TTYSM1_TIMER9
	bool "Use timer 9 (16-bit)"

config MN10300_TTYSM1_TIMER3
	bool "Use timer 3 (8-bit)"

endchoice

#
# /dev/ttySM2
#
config MN10300_TTYSM2
	bool "Enable SIF2 (/dev/ttySM2)"
	depends on MN10300_TTYSM && MN10300_PROC_HAS_TTYSM2
	help
	  Enable access to SIF2 through /dev/ttySM2 or gdb-stub

choice
	prompt "Select the timer to supply the clock for SIF2"
	default MN10300_TTYSM0_TIMER10
	depends on MN10300_TTYSM2

config MN10300_TTYSM2_TIMER10
	bool "Use timer 10 (16-bit)"

endchoice

config MN10300_TTYSM2_CTS
	bool "Enable the use of the CTS line /dev/ttySM2"
	depends on MN10300_TTYSM2

endmenu

source "mm/Kconfig"

menu "Power management options"
source kernel/power/Kconfig
endmenu

endmenu


menu "Executable formats"

source "fs/Kconfig.binfmt"

endmenu

source "net/Kconfig"

source "drivers/Kconfig"

source "fs/Kconfig"

source "arch/mn10300/Kconfig.debug"

source "security/Kconfig"

source "crypto/Kconfig"

source "lib/Kconfig"

source "arch/mn10300/oprofile/Kconfig"
+135 −0
Original line number Diff line number Diff line
menu "Kernel hacking"

source "lib/Kconfig.debug"

config DEBUG_STACKOVERFLOW
	bool "Check for stack overflows"
	depends on DEBUG_KERNEL

config DEBUG_DECOMPRESS_KERNEL
	bool "Using serial port during decompressing kernel"
	depends on DEBUG_KERNEL
	default n
	help
	  If you say Y here you will confirm the start and the end of
	  decompressing Linux seeing "Uncompressing Linux... " and
	  "Ok, booting the kernel.\n" on console.

config KPROBES
	bool "Kprobes"
	depends on DEBUG_KERNEL
	help
	  Kprobes allows you to trap at almost any kernel address and
	  execute a callback function.  register_kprobe() establishes
	  a probepoint and specifies the callback.  Kprobes is useful
	  for kernel debugging, non-intrusive instrumentation and testing.
	  If in doubt, say "N".

config GDBSTUB
	bool "Remote GDB kernel debugging"
	depends on DEBUG_KERNEL
	select DEBUG_INFO
	select FRAME_POINTER
	help
	  If you say Y here, it will be possible to remotely debug the kernel
	  using gdb. This enlarges your kernel ELF image disk size by several
	  megabytes and requires a machine with more than 16 MB, better 32 MB
	  RAM to avoid excessive linking time. This is only useful for kernel
	  hackers. If unsure, say N.

config GDBSTUB_IMMEDIATE
	bool "Break into GDB stub immediately"
	depends on GDBSTUB
	help
	  If you say Y here, GDB stub will break into the program as soon as
	  possible, leaving the program counter at the beginning of
	  start_kernel() in init/main.c.

config GDB_CONSOLE
	bool "Console output to GDB"
	depends on GDBSTUB
	help
	  If you are using GDB for remote debugging over a serial port and
	  would like kernel messages to be formatted into GDB $O packets so
	  that GDB prints them as program output, say 'Y'.

config GDBSTUB_DEBUGGING
	bool "Debug GDB stub by messages to serial port"
	depends on GDBSTUB
	help
	  This causes debugging messages to be displayed at various points
	  during execution of the GDB stub routines. Such messages will be
	  displayed on ttyS0 if that isn't the GDB stub's port, or ttySM0
	  otherwise.

config GDBSTUB_DEBUG_ENTRY
	bool "Debug GDB stub entry"
	depends on GDBSTUB_DEBUGGING
	help
	  This option causes information to be displayed about entry to or exit
	  from the main GDB stub routine.

config GDBSTUB_DEBUG_PROTOCOL
	bool "Debug GDB stub protocol"
	depends on GDBSTUB_DEBUGGING
	help
	  This option causes information to be displayed about the GDB remote
	  protocol messages generated exchanged with GDB.

config GDBSTUB_DEBUG_IO
	bool "Debug GDB stub I/O"
	depends on GDBSTUB_DEBUGGING
	help
	  This option causes information to be displayed about GDB stub's
	  low-level I/O.

config GDBSTUB_DEBUG_BREAKPOINT
	bool "Debug GDB stub breakpoint management"
	depends on GDBSTUB_DEBUGGING
	help
	  This option causes information to be displayed about GDB stub's
	  breakpoint management.

choice
	prompt "GDB stub port"
	default GDBSTUB_TTYSM0
	depends on GDBSTUB
	help
	  Select the serial port used for GDB-stub.

config GDBSTUB_ON_TTYSM0
	bool "/dev/ttySM0 [SIF0]"
	depends on MN10300_TTYSM0
	select GDBSTUB_ON_TTYSMx

config GDBSTUB_ON_TTYSM1
	bool "/dev/ttySM1 [SIF1]"
	depends on MN10300_TTYSM1
	select GDBSTUB_ON_TTYSMx

config GDBSTUB_ON_TTYSM2
	bool "/dev/ttySM2 [SIF2]"
	depends on MN10300_TTYSM2
	select GDBSTUB_ON_TTYSMx

config GDBSTUB_ON_TTYS0
	bool "/dev/ttyS0"
	select GDBSTUB_ON_TTYSx

config GDBSTUB_ON_TTYS1
	bool "/dev/ttyS1"
	select GDBSTUB_ON_TTYSx

endchoice

config GDBSTUB_ON_TTYSMx
	bool
	depends on GDBSTUB_ON_TTYSM0 || GDBSTUB_ON_TTYSM1 || GDBSTUB_ON_TTYSM2
	default y

config GDBSTUB_ON_TTYSx
	bool
	depends on GDBSTUB_ON_TTYS0 || GDBSTUB_ON_TTYS1
	default y

endmenu
Loading