You've already forked linux-rockchip
mirror of
https://github.com/armbian/linux-rockchip.git
synced 2026-01-06 11:08:10 -08:00
[PATCH] xtensa: Architecture support for Tensilica Xtensa Part 8
The attached patches provides part 8 of an architecture implementation for the Tensilica Xtensa CPU series. Signed-off-by: Chris Zankel <chris@zankel.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
committed by
Linus Torvalds
parent
e344b63eee
commit
7282bee787
531
arch/xtensa/configs/iss_defconfig
Normal file
531
arch/xtensa/configs/iss_defconfig
Normal file
File diff suppressed because it is too large
Load Diff
13
arch/xtensa/platform-iss/Makefile
Normal file
13
arch/xtensa/platform-iss/Makefile
Normal file
@@ -0,0 +1,13 @@
|
||||
# $Id: Makefile,v 1.1.1.1 2002/08/28 16:10:14 aroll Exp $
|
||||
#
|
||||
# Makefile for the Xtensa Instruction Set Simulator (ISS)
|
||||
# "prom monitor" library routines under Linux.
|
||||
#
|
||||
# Note! Dependencies are done automagically by 'make dep', which also
|
||||
# removes any old dependencies. DON'T put your own dependencies here
|
||||
# unless it's something special (ie not a .c file).
|
||||
#
|
||||
# Note 2! The CFLAGS definitions are in the main makefile...
|
||||
|
||||
obj-y = io.o console.o setup.o network.o
|
||||
|
||||
303
arch/xtensa/platform-iss/console.c
Normal file
303
arch/xtensa/platform-iss/console.c
Normal file
@@ -0,0 +1,303 @@
|
||||
/*
|
||||
* arch/xtensa/platform-iss/console.c
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*
|
||||
* Copyright (C) 2001-2005 Tensilica Inc.
|
||||
* Authors Christian Zankel, Joe Taylor
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/config.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/console.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/mm.h>
|
||||
#include <linux/major.h>
|
||||
#include <linux/param.h>
|
||||
#include <linux/serial.h>
|
||||
#include <linux/serialP.h>
|
||||
#include <linux/console.h>
|
||||
|
||||
#include <asm/uaccess.h>
|
||||
#include <asm/irq.h>
|
||||
|
||||
#include <xtensa/simcall.h>
|
||||
|
||||
#include <linux/tty.h>
|
||||
#include <linux/tty_flip.h>
|
||||
|
||||
#ifdef SERIAL_INLINE
|
||||
#define _INLINE_ inline
|
||||
#endif
|
||||
|
||||
#define SERIAL_MAX_NUM_LINES 1
|
||||
#define SERIAL_TIMER_VALUE (20 * HZ)
|
||||
|
||||
static struct tty_driver *serial_driver;
|
||||
static struct timer_list serial_timer;
|
||||
|
||||
static DEFINE_SPINLOCK(timer_lock);
|
||||
|
||||
int errno;
|
||||
|
||||
static int __simc (int a, int b, int c, int d, int e, int f)
|
||||
{
|
||||
int ret;
|
||||
__asm__ __volatile__ ("simcall\n"
|
||||
"mov %0, a2\n"
|
||||
"mov %1, a3\n" : "=a" (ret), "=a" (errno)
|
||||
: : "a2", "a3");
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char *serial_version = "0.1";
|
||||
static char *serial_name = "ISS serial driver";
|
||||
|
||||
/*
|
||||
* This routine is called whenever a serial port is opened. It
|
||||
* enables interrupts for a serial port, linking in its async structure into
|
||||
* the IRQ chain. It also performs the serial-specific
|
||||
* initialization for the tty structure.
|
||||
*/
|
||||
|
||||
static void rs_poll(unsigned long);
|
||||
|
||||
static int rs_open(struct tty_struct *tty, struct file * filp)
|
||||
{
|
||||
int line = tty->index;
|
||||
|
||||
if ((line < 0) || (line >= SERIAL_MAX_NUM_LINES))
|
||||
return -ENODEV;
|
||||
|
||||
spin_lock(&timer_lock);
|
||||
|
||||
if (tty->count == 1) {
|
||||
init_timer(&serial_timer);
|
||||
serial_timer.data = (unsigned long) tty;
|
||||
serial_timer.function = rs_poll;
|
||||
mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE);
|
||||
}
|
||||
spin_unlock(&timer_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* ------------------------------------------------------------
|
||||
* iss_serial_close()
|
||||
*
|
||||
* This routine is called when the serial port gets closed. First, we
|
||||
* wait for the last remaining data to be sent. Then, we unlink its
|
||||
* async structure from the interrupt chain if necessary, and we free
|
||||
* that IRQ if nothing is left in the chain.
|
||||
* ------------------------------------------------------------
|
||||
*/
|
||||
static void rs_close(struct tty_struct *tty, struct file * filp)
|
||||
{
|
||||
spin_lock(&timer_lock);
|
||||
if (tty->count == 1)
|
||||
del_timer_sync(&serial_timer);
|
||||
spin_unlock(&timer_lock);
|
||||
}
|
||||
|
||||
|
||||
static int rs_write(struct tty_struct * tty,
|
||||
const unsigned char *buf, int count)
|
||||
{
|
||||
/* see drivers/char/serialX.c to reference original version */
|
||||
|
||||
__simc (SYS_write, 1, (unsigned long)buf, count, 0, 0);
|
||||
return count;
|
||||
}
|
||||
|
||||
static void rs_poll(unsigned long priv)
|
||||
{
|
||||
struct tty_struct* tty = (struct tty_struct*) priv;
|
||||
|
||||
struct timeval tv = { .tv_sec = 0, .tv_usec = 0 };
|
||||
int i = 0;
|
||||
unsigned char c;
|
||||
|
||||
spin_lock(&timer_lock);
|
||||
|
||||
while (__simc(SYS_select_one, 0, XTISS_SELECT_ONE_READ, (int)&tv,0,0)){
|
||||
__simc (SYS_read, 0, (unsigned long)&c, 1, 0, 0);
|
||||
tty->flip.count++;
|
||||
*tty->flip.char_buf_ptr++ = c;
|
||||
*tty->flip.flag_buf_ptr++ = TTY_NORMAL;
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i)
|
||||
tty_flip_buffer_push(tty);
|
||||
|
||||
|
||||
mod_timer(&serial_timer, jiffies + SERIAL_TIMER_VALUE);
|
||||
spin_unlock(&timer_lock);
|
||||
}
|
||||
|
||||
|
||||
static void rs_put_char(struct tty_struct *tty, unsigned char ch)
|
||||
{
|
||||
char buf[2];
|
||||
|
||||
if (!tty)
|
||||
return;
|
||||
|
||||
buf[0] = ch;
|
||||
buf[1] = '\0'; /* Is this NULL necessary? */
|
||||
__simc (SYS_write, 1, (unsigned long) buf, 1, 0, 0);
|
||||
}
|
||||
|
||||
static void rs_flush_chars(struct tty_struct *tty)
|
||||
{
|
||||
}
|
||||
|
||||
static int rs_write_room(struct tty_struct *tty)
|
||||
{
|
||||
/* Let's say iss can always accept 2K characters.. */
|
||||
return 2 * 1024;
|
||||
}
|
||||
|
||||
static int rs_chars_in_buffer(struct tty_struct *tty)
|
||||
{
|
||||
/* the iss doesn't buffer characters */
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void rs_hangup(struct tty_struct *tty)
|
||||
{
|
||||
/* Stub, once again.. */
|
||||
}
|
||||
|
||||
static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
|
||||
{
|
||||
/* Stub, once again.. */
|
||||
}
|
||||
|
||||
static int rs_read_proc(char *page, char **start, off_t off, int count,
|
||||
int *eof, void *data)
|
||||
{
|
||||
int len = 0;
|
||||
off_t begin = 0;
|
||||
|
||||
len += sprintf(page, "serinfo:1.0 driver:%s\n", serial_version);
|
||||
*eof = 1;
|
||||
|
||||
if (off >= len + begin)
|
||||
return 0;
|
||||
|
||||
*start = page + (off - begin);
|
||||
return ((count < begin + len - off) ? count : begin + len - off);
|
||||
}
|
||||
|
||||
|
||||
int register_serial(struct serial_struct*);
|
||||
void unregister_serial(int);
|
||||
|
||||
static struct tty_operations serial_ops = {
|
||||
.open = rs_open,
|
||||
.close = rs_close,
|
||||
.write = rs_write,
|
||||
.put_char = rs_put_char,
|
||||
.flush_chars = rs_flush_chars,
|
||||
.write_room = rs_write_room,
|
||||
.chars_in_buffer = rs_chars_in_buffer,
|
||||
.hangup = rs_hangup,
|
||||
.wait_until_sent = rs_wait_until_sent,
|
||||
.read_proc = rs_read_proc
|
||||
};
|
||||
|
||||
int __init rs_init(void)
|
||||
{
|
||||
serial_driver = alloc_tty_driver(1);
|
||||
|
||||
printk ("%s %s\n", serial_name, serial_version);
|
||||
|
||||
/* Initialize the tty_driver structure */
|
||||
|
||||
serial_driver->owner = THIS_MODULE;
|
||||
serial_driver->driver_name = "iss_serial";
|
||||
serial_driver->name = "ttyS";
|
||||
serial_driver->major = TTY_MAJOR;
|
||||
serial_driver->minor_start = 64;
|
||||
serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
|
||||
serial_driver->subtype = SERIAL_TYPE_NORMAL;
|
||||
serial_driver->init_termios = tty_std_termios;
|
||||
serial_driver->init_termios.c_cflag =
|
||||
B9600 | CS8 | CREAD | HUPCL | CLOCAL;
|
||||
serial_driver->flags = TTY_DRIVER_REAL_RAW;
|
||||
|
||||
tty_set_operations(serial_driver, &serial_ops);
|
||||
|
||||
if (tty_register_driver(serial_driver))
|
||||
panic("Couldn't register serial driver\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static __exit void rs_exit(void)
|
||||
{
|
||||
int error;
|
||||
|
||||
if ((error = tty_unregister_driver(serial_driver)))
|
||||
printk("ISS_SERIAL: failed to unregister serial driver (%d)\n",
|
||||
error);
|
||||
put_tty_driver(serial_driver);
|
||||
}
|
||||
|
||||
|
||||
/* We use `late_initcall' instead of just `__initcall' as a workaround for
|
||||
* the fact that (1) simcons_tty_init can't be called before tty_init,
|
||||
* (2) tty_init is called via `module_init', (3) if statically linked,
|
||||
* module_init == device_init, and (4) there's no ordering of init lists.
|
||||
* We can do this easily because simcons is always statically linked, but
|
||||
* other tty drivers that depend on tty_init and which must use
|
||||
* `module_init' to declare their init routines are likely to be broken.
|
||||
*/
|
||||
|
||||
late_initcall(rs_init);
|
||||
|
||||
|
||||
#ifdef CONFIG_SERIAL_CONSOLE
|
||||
|
||||
static void iss_console_write(struct console *co, const char *s, unsigned count)
|
||||
{
|
||||
int len = strlen(s);
|
||||
|
||||
if (s != 0 && *s != 0)
|
||||
__simc (SYS_write, 1, (unsigned long)s,
|
||||
count < len ? count : len,0,0);
|
||||
}
|
||||
|
||||
static struct tty_driver* iss_console_device(struct console *c, int *index)
|
||||
{
|
||||
*index = c->index;
|
||||
return serial_driver;
|
||||
}
|
||||
|
||||
|
||||
static struct console sercons = {
|
||||
.name = "ttyS",
|
||||
.write = iss_console_write,
|
||||
.device = iss_console_device,
|
||||
.flags = CON_PRINTBUFFER,
|
||||
.index = -1
|
||||
};
|
||||
|
||||
static int __init iss_console_init(void)
|
||||
{
|
||||
register_console(&sercons);
|
||||
return 0;
|
||||
}
|
||||
|
||||
console_initcall(iss_console_init);
|
||||
|
||||
#endif /* CONFIG_SERIAL_CONSOLE */
|
||||
|
||||
32
arch/xtensa/platform-iss/io.c
Normal file
32
arch/xtensa/platform-iss/io.c
Normal file
@@ -0,0 +1,32 @@
|
||||
/* This file isn't really needed right now. */
|
||||
|
||||
#if 0
|
||||
|
||||
#include <asm/io.h>
|
||||
#include <xtensa/simcall.h>
|
||||
|
||||
extern int __simc ();
|
||||
|
||||
|
||||
char iss_serial_getc()
|
||||
{
|
||||
char c;
|
||||
__simc( SYS_read, 0, &c, 1 );
|
||||
return c;
|
||||
}
|
||||
|
||||
void iss_serial_putc( char c )
|
||||
{
|
||||
__simc( SYS_write, 1, &c, 1 );
|
||||
}
|
||||
|
||||
void iss_serial_puts( char *s )
|
||||
{
|
||||
if( s != 0 && *s != 0 )
|
||||
__simc( SYS_write, 1, s, strlen(s) );
|
||||
}
|
||||
|
||||
/*#error Need I/O ports to specific hardware!*/
|
||||
|
||||
#endif
|
||||
|
||||
855
arch/xtensa/platform-iss/network.c
Normal file
855
arch/xtensa/platform-iss/network.c
Normal file
File diff suppressed because it is too large
Load Diff
112
arch/xtensa/platform-iss/setup.c
Normal file
112
arch/xtensa/platform-iss/setup.c
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
*
|
||||
* arch/xtensa/platform-iss/setup.c
|
||||
*
|
||||
* Platform specific initialization.
|
||||
*
|
||||
* Authors: Chris Zankel <chris@zankel.net>
|
||||
* Joe Taylor <joe@tensilica.com>
|
||||
*
|
||||
* Copyright 2001 - 2005 Tensilica Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2 of the License, or (at your
|
||||
* option) any later version.
|
||||
*
|
||||
*/
|
||||
#include <linux/config.h>
|
||||
#include <linux/stddef.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/errno.h>
|
||||
#include <linux/reboot.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/kdev_t.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/major.h>
|
||||
#include <linux/blkdev.h>
|
||||
#include <linux/console.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/stringify.h>
|
||||
#include <linux/notifier.h>
|
||||
|
||||
#include <asm/platform.h>
|
||||
#include <asm/bootparam.h>
|
||||
|
||||
|
||||
void __init platform_init(bp_tag_t* bootparam)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void platform_halt(void)
|
||||
{
|
||||
printk (" ** Called platform_halt(), looping forever! **\n");
|
||||
while (1);
|
||||
}
|
||||
|
||||
void platform_power_off(void)
|
||||
{
|
||||
printk (" ** Called platform_power_off(), looping forever! **\n");
|
||||
while (1);
|
||||
}
|
||||
void platform_restart(void)
|
||||
{
|
||||
/* Flush and reset the mmu, simulate a processor reset, and
|
||||
* jump to the reset vector. */
|
||||
|
||||
__asm__ __volatile__("movi a2, 15\n\t"
|
||||
"wsr a2, " __stringify(ICOUNTLEVEL) "\n\t"
|
||||
"movi a2, 0\n\t"
|
||||
"wsr a2, " __stringify(ICOUNT) "\n\t"
|
||||
"wsr a2, " __stringify(IBREAKENABLE) "\n\t"
|
||||
"wsr a2, " __stringify(LCOUNT) "\n\t"
|
||||
"movi a2, 0x1f\n\t"
|
||||
"wsr a2, " __stringify(PS) "\n\t"
|
||||
"isync\n\t"
|
||||
"jx %0\n\t"
|
||||
:
|
||||
: "a" (XCHAL_RESET_VECTOR_VADDR)
|
||||
: "a2");
|
||||
|
||||
/* control never gets here */
|
||||
}
|
||||
|
||||
extern void iss_net_poll(void);
|
||||
|
||||
const char twirl[]="|/-\\|/-\\";
|
||||
|
||||
void platform_heartbeat(void)
|
||||
{
|
||||
#if 0
|
||||
static int i = 0, j = 0;
|
||||
|
||||
if (--i < 0) {
|
||||
i = 99;
|
||||
printk("\r%c\r", twirl[j++]);
|
||||
if (j == 8)
|
||||
j = 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
static int
|
||||
iss_panic_event(struct notifier_block *this, unsigned long event, void *ptr)
|
||||
{
|
||||
__asm__ __volatile__("movi a2, -1; simcall\n");
|
||||
return NOTIFY_DONE;
|
||||
}
|
||||
|
||||
static struct notifier_block iss_panic_block = {
|
||||
iss_panic_event,
|
||||
NULL,
|
||||
0
|
||||
};
|
||||
|
||||
void __init platform_setup(char **p_cmdline)
|
||||
{
|
||||
notifier_chain_register(&panic_notifier_list, &iss_panic_block);
|
||||
}
|
||||
29
include/asm-xtensa/platform-iss/hardware.h
Normal file
29
include/asm-xtensa/platform-iss/hardware.h
Normal file
@@ -0,0 +1,29 @@
|
||||
/*
|
||||
* include/asm-xtensa/platform-iss/hardware.h
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU General Public
|
||||
* License. See the file "COPYING" in the main directory of this archive
|
||||
* for more details.
|
||||
*
|
||||
* Copyright (C) 2001 Tensilica Inc.
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file contains the default configuration of ISS.
|
||||
*/
|
||||
|
||||
#ifndef __ASM_XTENSA_ISS_HARDWARE
|
||||
#define __ASM_XTENSA_ISS_HARDWARE
|
||||
|
||||
/*
|
||||
* Memory configuration.
|
||||
*/
|
||||
|
||||
#define PLATFORM_DEFAULT_MEM_START XSHAL_RAM_PADDR
|
||||
#define PLATFORM_DEFAULT_MEM_SIZE XSHAL_RAM_VSIZE
|
||||
|
||||
/*
|
||||
* Interrupt configuration.
|
||||
*/
|
||||
|
||||
#endif /* __ASM_XTENSA_ISS_HARDWARE */
|
||||
92
include/asm-xtensa/platform.h
Normal file
92
include/asm-xtensa/platform.h
Normal file
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* include/asm-xtensa/platform.h
|
||||
*
|
||||
* Platform specific functions
|
||||
*
|
||||
* This file is subject to the terms and conditions of the GNU General
|
||||
* Public License. See the file "COPYING" in the main directory of
|
||||
* this archive for more details.
|
||||
*
|
||||
* Copyright (C) 2001 - 2005 Tensilica Inc.
|
||||
*/
|
||||
|
||||
#ifndef _XTENSA_PLATFORM_H
|
||||
#define _XTENSA_PLATFORM_H
|
||||
|
||||
#include <linux/config.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/pci.h>
|
||||
|
||||
#include <asm/bootparam.h>
|
||||
|
||||
/*
|
||||
* platform_init is called before the mmu is initialized to give the
|
||||
* platform a early hook-up. bp_tag_t is a list of configuration tags
|
||||
* passed from the boot-loader.
|
||||
*/
|
||||
extern void platform_init(bp_tag_t*);
|
||||
|
||||
/*
|
||||
* platform_setup is called from setup_arch with a pointer to the command-line
|
||||
* string.
|
||||
*/
|
||||
extern void platform_setup (char **);
|
||||
|
||||
/*
|
||||
* platform_init_irq is called from init_IRQ.
|
||||
*/
|
||||
extern void platform_init_irq (void);
|
||||
|
||||
/*
|
||||
* platform_restart is called to restart the system.
|
||||
*/
|
||||
extern void platform_restart (void);
|
||||
|
||||
/*
|
||||
* platform_halt is called to stop the system and halt.
|
||||
*/
|
||||
extern void platform_halt (void);
|
||||
|
||||
/*
|
||||
* platform_power_off is called to stop the system and power it off.
|
||||
*/
|
||||
extern void platform_power_off (void);
|
||||
|
||||
/*
|
||||
* platform_idle is called from the idle function.
|
||||
*/
|
||||
extern void platform_idle (void);
|
||||
|
||||
/*
|
||||
* platform_heartbeat is called every HZ
|
||||
*/
|
||||
extern void platform_heartbeat (void);
|
||||
|
||||
/*
|
||||
* platform_pcibios_init is called to allow the platform to setup the pci bus.
|
||||
*/
|
||||
extern void platform_pcibios_init (void);
|
||||
|
||||
/*
|
||||
* platform_pcibios_fixup allows to modify the PCI configuration.
|
||||
*/
|
||||
extern int platform_pcibios_fixup (void);
|
||||
|
||||
/*
|
||||
* platform_calibrate_ccount calibrates cpu clock freq (CONFIG_XTENSA_CALIBRATE)
|
||||
*/
|
||||
extern void platform_calibrate_ccount (void);
|
||||
|
||||
/*
|
||||
* platform_get_rtc_time returns RTC seconds (returns 0 for no error)
|
||||
*/
|
||||
extern int platform_get_rtc_time(time_t*);
|
||||
|
||||
/*
|
||||
* platform_set_rtc_time set RTC seconds (returns 0 for no error)
|
||||
*/
|
||||
extern int platform_set_rtc_time(time_t);
|
||||
|
||||
|
||||
#endif /* _XTENSA_PLATFORM_H */
|
||||
|
||||
Reference in New Issue
Block a user