1
0
mirror of git://projects.qi-hardware.com/openwrt-xburst.git synced 2025-04-21 12:27:27 +03:00

[adm5120] switch to 2.6.24

git-svn-id: svn://svn.openwrt.org/openwrt/trunk@10427 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
juhosg
2008-02-09 10:29:28 +00:00
parent 119fa4474f
commit d63beb8f0c
65 changed files with 102 additions and 3216 deletions

View File

@@ -27,7 +27,6 @@
#include <linux/irq.h>
#include <linux/io.h>
#include <asm/bootinfo.h>
#include <asm/addrspace.h>
#include <adm5120_info.h>
@@ -50,7 +49,6 @@ void adm5120_halt(void)
{
local_irq_disable();
printk(KERN_NOTICE "\n** You can safely turn off the power\n");
while (1) {
if (cpu_wait)
cpu_wait();

View File

@@ -23,7 +23,6 @@
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/io.h>
#include <linux/version.h>
#include <asm/reboot.h>
#include <asm/time.h>
@@ -60,11 +59,6 @@ void __init plat_mem_setup(void)
adm5120_mem_init();
adm5120_report();
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
extern void plat_time_init(void) __init;
board_time_init = plat_time_init;
#endif
_machine_restart = adm5120_restart;
_machine_halt = adm5120_halt;
pm_power_off = adm5120_halt;

View File

@@ -21,7 +21,6 @@
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/timex.h>
#include <linux/version.h>
#include <asm/irq.h>
#include <asm/cpu.h>
@@ -34,13 +33,3 @@ void __init plat_time_init(void)
{
mips_hpt_frequency = adm5120_speed / 2;
}
#if (LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24))
void __init plat_timer_setup(struct irqaction *irq)
{
clear_c0_status(ST0_BEV);
/* Install ISR for CPU Counter interrupt */
setup_irq(ADM5120_IRQ_COUNTER, irq);
}
#endif

View File

@@ -1,206 +0,0 @@
/*
* ADM5120_WDT 0.01: Infineon ADM5120 SoC watchdog driver
* Copyright (c) Ondrej Zajicek <santiago@crfreenet.org>, 2007
*
* based on
*
* RC32434_WDT 0.01: IDT Interprise 79RC32434 watchdog driver
*
* 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/module.h>
#include <linux/types.h>
#include <linux/fs.h>
#include <linux/miscdevice.h>
#include <linux/watchdog.h>
#include <asm/bootinfo.h>
#include <adm5120_info.h>
#include <adm5120_defs.h>
#include <adm5120_irq.h>
#include <adm5120_switch.h>
#define DEFAULT_TIMEOUT 15 /* (secs) Default is 15 seconds */
#define MAX_TIMEOUT 327
/* Max is 327 seconds, counter is 15-bit integer, step is 10 ms */
#define NAME "adm5120_wdt"
#define VERSION "0.1"
static int expect_close = 0;
static int access = 0;
static unsigned int timeout = DEFAULT_TIMEOUT;
static int nowayout = WATCHDOG_NOWAYOUT;
module_param(nowayout, int, 0);
MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
MODULE_LICENSE("GPL");
static inline void wdt_set_timeout(void)
{
u32 val = (1 << 31) | (((timeout * 100) & 0x7FFF) << 16);
SW_WRITE_REG(SWITCH_REG_WDOG0, val);
}
/*
It looks like WDOG0-register-write don't modify counter,
but WDOG0-register-read resets counter.
*/
static inline void wdt_reset_counter(void)
{
SW_READ_REG(SWITCH_REG_WDOG0);
}
static inline void wdt_disable(void)
{
SW_WRITE_REG(SWITCH_REG_WDOG0, 0x7FFF0000);
}
static int wdt_open(struct inode *inode, struct file *file)
{
/* Allow only one person to hold it open */
if (access)
return -EBUSY;
if (nowayout) {
__module_get(THIS_MODULE);
}
/* Activate timer */
wdt_reset_counter();
wdt_set_timeout();
printk(KERN_INFO NAME ": enabling watchdog timer\n");
access = 1;
return 0;
}
static int wdt_release(struct inode *inode, struct file *file)
{
/*
* Shut off the timer.
* Lock it in if it's a module and we set nowayout
*/
if (expect_close && (nowayout == 0)) {
wdt_disable();
printk(KERN_INFO NAME ": disabling watchdog timer\n");
module_put(THIS_MODULE);
} else {
printk(KERN_CRIT NAME ": device closed unexpectedly. WDT will not stop!\n");
}
access = 0;
return 0;
}
static ssize_t wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
{
/* Refresh the timer. */
if (len) {
if (!nowayout) {
size_t i;
/* In case it was set long ago */
expect_close = 0;
for (i = 0; i != len; i++) {
char c;
if (get_user(c, data + i))
return -EFAULT;
if (c == 'V')
expect_close = 1;
}
}
wdt_reset_counter();
return len;
}
return 0;
}
static int wdt_ioctl(struct inode *inode, struct file *file,
unsigned int cmd, unsigned long arg)
{
int new_timeout;
static struct watchdog_info ident = {
.options = WDIOF_SETTIMEOUT |
WDIOF_KEEPALIVEPING |
WDIOF_MAGICCLOSE,
.firmware_version = 0,
.identity = "ADM5120_WDT Watchdog",
};
switch (cmd) {
default:
return -ENOTTY;
case WDIOC_GETSUPPORT:
if(copy_to_user((struct watchdog_info *)arg, &ident, sizeof(ident)))
return -EFAULT;
return 0;
case WDIOC_GETSTATUS:
case WDIOC_GETBOOTSTATUS:
return put_user(0,(int *)arg);
case WDIOC_KEEPALIVE:
wdt_reset_counter();
return 0;
case WDIOC_SETTIMEOUT:
if (get_user(new_timeout, (int *)arg))
return -EFAULT;
if (new_timeout < 1)
return -EINVAL;
if (new_timeout > MAX_TIMEOUT)
return -EINVAL;
timeout = new_timeout;
wdt_set_timeout();
/* Fall */
case WDIOC_GETTIMEOUT:
return put_user(timeout, (int *)arg);
}
}
static struct file_operations wdt_fops = {
owner: THIS_MODULE,
llseek: no_llseek,
write: wdt_write,
ioctl: wdt_ioctl,
open: wdt_open,
release: wdt_release,
};
static struct miscdevice wdt_miscdev = {
minor: WATCHDOG_MINOR,
name: "watchdog",
fops: &wdt_fops,
};
static char banner[] __initdata = KERN_INFO NAME ": Watchdog Timer version " VERSION "\n";
static int __init watchdog_init(void)
{
int ret;
ret = misc_register(&wdt_miscdev);
if (ret)
return ret;
wdt_disable();
printk(banner);
return 0;
}
static void __exit watchdog_exit(void)
{
misc_deregister(&wdt_miscdev);
}
module_init(watchdog_init);
module_exit(watchdog_exit);

View File

@@ -93,8 +93,14 @@
/* ------------------------------------------------------------------------ */
struct adm5120_if_priv {
struct net_device *dev;
unsigned int vlan_no;
unsigned int port_mask;
#ifdef CONFIG_ADM5120_SWITCH_NAPI
struct napi_struct napi;
#endif
};
struct dma_desc {
@@ -333,7 +339,6 @@ static void sw_dump_regs(void)
SW_DBG("rlda: %08X\n", t);
}
/* ------------------------------------------------------------------------ */
static inline void adm5120_rx_dma_update(struct dma_desc *desc,
@@ -495,9 +500,11 @@ static void adm5120_switch_tx(void)
}
#ifdef CONFIG_ADM5120_SWITCH_NAPI
static int adm5120_if_poll(struct net_device *dev, int *budget)
static int adm5120_if_poll(struct napi_struct *napi, int limit)
{
int limit = min(dev->quota, *budget);
struct adm5120_if_priv *priv = container_of(napi,
struct adm5120_if_priv, napi);
struct net_device *dev = priv->dev;
int done;
u32 status;
@@ -509,13 +516,10 @@ static int adm5120_if_poll(struct net_device *dev, int *budget)
SW_DBG("%s: processing RX ring\n", dev->name);
done = adm5120_switch_rx(limit);
*budget -= done;
dev->quota -= done;
status = sw_int_status() & SWITCH_INTS_POLL;
if ((done < limit) && (!status)) {
SW_DBG("disable polling mode for %s\n", dev->name);
netif_rx_complete(dev);
netif_rx_complete(dev, napi);
sw_int_unmask(SWITCH_INTS_POLL);
return 0;
}
@@ -541,10 +545,12 @@ static irqreturn_t adm5120_switch_irq(int irq, void *dev_id)
if (status & SWITCH_INTS_POLL) {
struct net_device *dev = dev_id;
struct adm5120_if_priv *priv = netdev_priv(dev);
sw_dump_intr_mask("poll ints", status);
SW_DBG("enable polling mode for %s\n", dev->name);
sw_int_mask(SWITCH_INTS_POLL);
netif_rx_schedule(dev);
netif_rx_schedule(dev, &priv->napi);
}
#else
sw_int_ack(status);
@@ -779,12 +785,31 @@ static void adm5120_switch_set_vlan_ports(unsigned int vlan, u32 ports)
/* ------------------------------------------------------------------------ */
#ifdef CONFIG_ADM5120_SWITCH_NAPI
static inline void adm5120_if_napi_enable(struct net_device *dev)
{
struct adm5120_if_priv *priv = netdev_priv(dev);
napi_enable(&priv->napi);
}
static inline void adm5120_if_napi_disable(struct net_device *dev)
{
struct adm5120_if_priv *priv = netdev_priv(dev);
napi_disable(&priv->napi);
}
#else
static inline void adm5120_if_napi_enable(struct net_device *dev) {}
static inline void adm5120_if_napi_disable(struct net_device *dev) {}
#endif /* CONFIG_ADM5120_SWITCH_NAPI */
static int adm5120_if_open(struct net_device *dev)
{
u32 t;
int err;
int i;
adm5120_if_napi_enable(dev);
err = request_irq(dev->irq, adm5120_switch_irq,
(IRQF_SHARED | IRQF_DISABLED), dev->name, dev);
if (err) {
@@ -809,6 +834,7 @@ static int adm5120_if_open(struct net_device *dev)
return 0;
err:
adm5120_if_napi_disable(dev);
return err;
}
@@ -818,6 +844,7 @@ static int adm5120_if_stop(struct net_device *dev)
int i;
netif_stop_queue(dev);
adm5120_if_napi_disable(dev);
/* disable port if not assigned to other devices */
t = sw_read_reg(SWITCH_REG_PORT_CONF0);
@@ -1001,6 +1028,9 @@ static struct net_device *adm5120_if_alloc(void)
if (!dev)
return NULL;
priv = netdev_priv(dev);
priv->dev = dev;
dev->irq = ADM5120_IRQ_SWITCH;
dev->open = adm5120_if_open;
dev->hard_start_xmit = adm5120_if_hard_start_xmit;
@@ -1010,12 +1040,10 @@ static struct net_device *adm5120_if_alloc(void)
dev->tx_timeout = adm5120_if_tx_timeout;
dev->watchdog_timeo = TX_TIMEOUT;
dev->set_mac_address = adm5120_if_set_mac_address;
#ifdef CONFIG_ADM5120_SWITCH_NAPI
dev->poll = adm5120_if_poll;
dev->weight = 64;
#endif
SET_MODULE_OWNER(dev);
#ifdef CONFIG_ADM5120_SWITCH_NAPI
netif_napi_add(dev, &priv->napi, adm5120_if_poll, 64);
#endif
return dev;
}

View File

@@ -1,520 +0,0 @@
/*
* Serial driver for ADM5120 SoC
*
* Derived from drivers/serial/uart00.c
* Copyright 2001 Altera Corporation
*
* Some pieces are derived from the ADMtek 2.4 serial driver.
* Copyright (C) ADMtek Incorporated, 2003
* daniell@admtek.com.tw
* Which again was derived from drivers/char/serial.c
* Copyright (C) Linus Torvalds et al.
*
* Copyright Jeroen Vreeken (pe1rxq@amsat.org), 2005
*/
#include <linux/autoconf.h>
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/ioport.h>
#include <linux/serial.h>
#include <linux/serial_core.h>
#include <linux/tty.h>
#include <linux/tty_flip.h>
#include <linux/console.h>
#include <asm/mach-adm5120/adm5120_defs.h>
#include <asm/mach-adm5120/adm5120_irq.h>
#define ADM5120_UART_REG(base, reg) \
(*(volatile u32 *)KSEG1ADDR((base)+(reg)))
#define ADM5120_UARTCLK_FREQ 62500000
#define ADM5120_UART_BAUDDIV(rate) ((unsigned long)(ADM5120_UARTCLK_FREQ/(16*(rate)) - 1))
#define ADM5120_UART_BAUD115200 ADM5120_UART_BAUDDIV(115200)
#define ADM5120_UART_DATA 0x00
#define ADM5120_UART_RS 0x04
#define ADM5120_UART_LCR_H 0x08
#define ADM5120_UART_LCR_M 0x0c
#define ADM5120_UART_LCR_L 0x10
#define ADM5120_UART_CR 0x14
#define ADM5120_UART_FR 0x18
#define ADM5120_UART_IR 0x1c
#define ADM5120_UART_FE 0x01
#define ADM5120_UART_PE 0x02
#define ADM5120_UART_BE 0x04
#define ADM5120_UART_OE 0x08
#define ADM5120_UART_ERR 0x0f
#define ADM5120_UART_FIFO_EN 0x10
#define ADM5120_UART_EN 0x01
#define ADM5120_UART_TIE 0x20
#define ADM5120_UART_RIE 0x50
#define ADM5120_UART_IE 0x78
#define ADM5120_UART_CTS 0x01
#define ADM5120_UART_DSR 0x02
#define ADM5120_UART_DCD 0x04
#define ADM5120_UART_TXFF 0x20
#define ADM5120_UART_TXFE 0x80
#define ADM5120_UART_RXFE 0x10
#define ADM5120_UART_BRK 0x01
#define ADM5120_UART_PEN 0x02
#define ADM5120_UART_EPS 0x04
#define ADM5120_UART_STP2 0x08
#define ADM5120_UART_W5 0x00
#define ADM5120_UART_W6 0x20
#define ADM5120_UART_W7 0x40
#define ADM5120_UART_W8 0x60
#define ADM5120_UART_MIS 0x01
#define ADM5120_UART_RIS 0x02
#define ADM5120_UART_TIS 0x04
#define ADM5120_UART_RTIS 0x08
static void adm5120ser_stop_tx(struct uart_port *port)
{
ADM5120_UART_REG(port->iobase, ADM5120_UART_CR) &= ~ADM5120_UART_TIE;
}
static void adm5120ser_irq_rx(struct uart_port *port)
{
struct tty_struct *tty = port->info->tty;
unsigned int status, ch, rds, flg, ignored = 0;
status = ADM5120_UART_REG(port->iobase, ADM5120_UART_FR);
while (!(status & ADM5120_UART_RXFE)) {
/*
* We need to read rds before reading the
* character from the fifo
*/
rds = ADM5120_UART_REG(port->iobase, ADM5120_UART_RS);
ch = ADM5120_UART_REG(port->iobase, ADM5120_UART_DATA);
port->icount.rx++;
if (tty->low_latency)
tty_flip_buffer_push(tty);
flg = TTY_NORMAL;
/*
* Note that the error handling code is
* out of the main execution path
*/
if (rds & ADM5120_UART_ERR)
goto handle_error;
if (uart_handle_sysrq_char(port, ch))
goto ignore_char;
error_return:
tty_insert_flip_char(tty, ch, flg);
ignore_char:
status = ADM5120_UART_REG(port->iobase, ADM5120_UART_FR);
}
out:
tty_flip_buffer_push(tty);
return;
handle_error:
ADM5120_UART_REG(port->iobase, ADM5120_UART_RS) = 0xff;
if (rds & ADM5120_UART_BE) {
port->icount.brk++;
if (uart_handle_break(port))
goto ignore_char;
} else if (rds & ADM5120_UART_PE)
port->icount.parity++;
else if (rds & ADM5120_UART_FE)
port->icount.frame++;
if (rds & ADM5120_UART_OE)
port->icount.overrun++;
if (rds & port->ignore_status_mask) {
if (++ignored > 100)
goto out;
goto ignore_char;
}
rds &= port->read_status_mask;
if (rds & ADM5120_UART_BE)
flg = TTY_BREAK;
else if (rds & ADM5120_UART_PE)
flg = TTY_PARITY;
else if (rds & ADM5120_UART_FE)
flg = TTY_FRAME;
if (rds & ADM5120_UART_OE) {
/*
* CHECK: does overrun affect the current character?
* ASSUMPTION: it does not.
*/
tty_insert_flip_char(tty, ch, flg);
ch = 0;
flg = TTY_OVERRUN;
}
#ifdef CONFIG_MAGIC_SYSRQ
port->sysrq = 0;
#endif
goto error_return;
}
static void adm5120ser_irq_tx(struct uart_port *port)
{
struct circ_buf *xmit = &port->info->xmit;
int count;
if (port->x_char) {
ADM5120_UART_REG(port->iobase, ADM5120_UART_DATA) =
port->x_char;
port->icount.tx++;
port->x_char = 0;
return;
}
if (uart_circ_empty(xmit) || uart_tx_stopped(port)) {
adm5120ser_stop_tx(port);
return;
}
count = port->fifosize >> 1;
do {
ADM5120_UART_REG(port->iobase, ADM5120_UART_DATA) =
xmit->buf[xmit->tail];
xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
port->icount.tx++;
if (uart_circ_empty(xmit))
break;
} while (--count > 0);
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_write_wakeup(port);
if (uart_circ_empty(xmit))
adm5120ser_stop_tx(port);
}
static void adm5120ser_irq_modem(struct uart_port *port)
{
unsigned int status;
status = ADM5120_UART_REG(port->iobase, ADM5120_UART_FR);
if (status & ADM5120_UART_DCD)
uart_handle_dcd_change(port, status & ADM5120_UART_DCD);
if (status & ADM5120_UART_DSR)
port->icount.dsr++;
if (status & ADM5120_UART_CTS)
uart_handle_cts_change(port, status & ADM5120_UART_CTS);
wake_up_interruptible(&port->info->delta_msr_wait);
}
static irqreturn_t adm5120ser_irq(int irq, void *dev_id)
{
struct uart_port *port = dev_id;
unsigned long ir = ADM5120_UART_REG(port->iobase, ADM5120_UART_IR);
if (ir & (ADM5120_UART_RIS | ADM5120_UART_RTIS))
adm5120ser_irq_rx(port);
if (ir & ADM5120_UART_TIS)
adm5120ser_irq_tx(port);
if (ir & ADM5120_UART_MIS) {
adm5120ser_irq_modem(port);
ADM5120_UART_REG(port->iobase, ADM5120_UART_IR) = 0xff;
}
return IRQ_HANDLED;
}
static unsigned int adm5120ser_tx_empty(struct uart_port *port)
{
unsigned int fr = ADM5120_UART_REG(port->iobase, ADM5120_UART_FR);
return (fr & ADM5120_UART_TXFE) ? TIOCSER_TEMT : 0;
}
static void adm5120ser_set_mctrl(struct uart_port *port, unsigned int mctrl)
{
}
static unsigned int adm5120ser_get_mctrl(struct uart_port *port)
{
unsigned int result = 0;
unsigned int fr = ADM5120_UART_REG(port->iobase, ADM5120_UART_FR);
if (fr & ADM5120_UART_CTS)
result |= TIOCM_CTS;
if (fr & ADM5120_UART_DSR)
result |= TIOCM_DSR;
if (fr & ADM5120_UART_DCD)
result |= TIOCM_CAR;
return result;
}
static void adm5120ser_start_tx(struct uart_port *port)
{
ADM5120_UART_REG(port->iobase, ADM5120_UART_CR) |= ADM5120_UART_TIE;
}
static void adm5120ser_stop_rx(struct uart_port *port)
{
ADM5120_UART_REG(port->iobase, ADM5120_UART_CR) &= ~ADM5120_UART_RIE;
}
static void adm5120ser_enable_ms(struct uart_port *port)
{
}
static void adm5120ser_break_ctl(struct uart_port *port, int break_state)
{
unsigned long flags;
unsigned long lcrh;
spin_lock_irqsave(&port->lock, flags);
lcrh = ADM5120_UART_REG(port->iobase, ADM5120_UART_LCR_H);
if (break_state == -1)
lcrh |= ADM5120_UART_BRK;
else
lcrh &= ~ADM5120_UART_BRK;
ADM5120_UART_REG(port->iobase, ADM5120_UART_LCR_H) = lcrh;
spin_unlock_irqrestore(&port->lock, flags);
}
static int adm5120ser_startup(struct uart_port *port)
{
int ret;
ret = request_irq(port->irq, adm5120ser_irq, 0, "ADM5120 UART", port);
if (ret) {
printk(KERN_ERR "Couldn't get irq %d\n", port->irq);
return ret;
}
ADM5120_UART_REG(port->iobase, ADM5120_UART_LCR_H) |=
ADM5120_UART_FIFO_EN;
ADM5120_UART_REG(port->iobase, ADM5120_UART_CR) |=
ADM5120_UART_EN | ADM5120_UART_IE;
return 0;
}
static void adm5120ser_shutdown(struct uart_port *port)
{
ADM5120_UART_REG(port->iobase, ADM5120_UART_CR) &= ~ADM5120_UART_IE;
free_irq(port->irq, port);
}
static void adm5120ser_set_termios(struct uart_port *port,
struct ktermios *termios, struct ktermios *old)
{
unsigned int baud, quot, lcrh;
unsigned long flags;
termios->c_cflag |= CREAD;
baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
quot = uart_get_divisor(port, baud);
lcrh = ADM5120_UART_FIFO_EN;
switch (termios->c_cflag & CSIZE) {
case CS5:
lcrh |= ADM5120_UART_W5;
break;
case CS6:
lcrh |= ADM5120_UART_W6;
break;
case CS7:
lcrh |= ADM5120_UART_W7;
break;
default:
lcrh |= ADM5120_UART_W8;
break;
}
if (termios->c_cflag & CSTOPB)
lcrh |= ADM5120_UART_STP2;
if (termios->c_cflag & PARENB) {
lcrh |= ADM5120_UART_PEN;
if (!(termios->c_cflag & PARODD))
lcrh |= ADM5120_UART_EPS;
}
spin_lock_irqsave(port->lock, flags);
ADM5120_UART_REG(port->iobase, ADM5120_UART_LCR_H) = lcrh;
/*
* Update the per-port timeout.
*/
uart_update_timeout(port, termios->c_cflag, baud);
port->read_status_mask = ADM5120_UART_OE;
if (termios->c_iflag & INPCK)
port->read_status_mask |= ADM5120_UART_FE | ADM5120_UART_PE;
if (termios->c_iflag & (BRKINT | PARMRK))
port->read_status_mask |= ADM5120_UART_BE;
/*
* Characters to ignore
*/
port->ignore_status_mask = 0;
if (termios->c_iflag & IGNPAR)
port->ignore_status_mask |= ADM5120_UART_FE | ADM5120_UART_PE;
if (termios->c_iflag & IGNBRK) {
port->ignore_status_mask |= ADM5120_UART_BE;
/*
* If we're ignoring parity and break indicators,
* ignore overruns to (for real raw support).
*/
if (termios->c_iflag & IGNPAR)
port->ignore_status_mask |= ADM5120_UART_OE;
}
quot = ADM5120_UART_BAUD115200;
ADM5120_UART_REG(port->iobase, ADM5120_UART_LCR_L) = quot & 0xff;
ADM5120_UART_REG(port->iobase, ADM5120_UART_LCR_M) = quot >> 8;
spin_unlock_irqrestore(&port->lock, flags);
}
static const char *adm5120ser_type(struct uart_port *port)
{
return port->type == PORT_ADM5120 ? "ADM5120" : NULL;
}
static void adm5120ser_config_port(struct uart_port *port, int flags)
{
if (flags & UART_CONFIG_TYPE)
port->type = PORT_ADM5120;
}
static void adm5120ser_release_port(struct uart_port *port)
{
release_mem_region(port->iobase, ADM5120_UART_SIZE);
}
static int adm5120ser_request_port(struct uart_port *port)
{
return request_mem_region(port->iobase, ADM5120_UART_SIZE,
"adm5120-uart") != NULL ? 0 : -EBUSY;
}
static struct uart_ops adm5120ser_ops = {
.tx_empty = adm5120ser_tx_empty,
.set_mctrl = adm5120ser_set_mctrl,
.get_mctrl = adm5120ser_get_mctrl,
.stop_tx = adm5120ser_stop_tx,
.start_tx = adm5120ser_start_tx,
.stop_rx = adm5120ser_stop_rx,
.enable_ms = adm5120ser_enable_ms,
.break_ctl = adm5120ser_break_ctl,
.startup = adm5120ser_startup,
.shutdown = adm5120ser_shutdown,
.set_termios = adm5120ser_set_termios,
.type = adm5120ser_type,
.config_port = adm5120ser_config_port,
.release_port = adm5120ser_release_port,
.request_port = adm5120ser_request_port,
};
static void adm5120console_put(const char c)
{
while ((ADM5120_UART_REG(ADM5120_UART0_BASE, ADM5120_UART_FR) &
ADM5120_UART_TXFF) != 0);
ADM5120_UART_REG(ADM5120_UART0_BASE, ADM5120_UART_DATA) = c;
}
static void adm5120console_write(struct console *con, const char *s,
unsigned int count)
{
while (count--) {
if (*s == '\n')
adm5120console_put('\r');
adm5120console_put(*s);
s++;
}
}
static int adm5120console_setup(struct console *con, char *options)
{
/* Set to 115200 baud, 8N1 and enable FIFO */
ADM5120_UART_REG(ADM5120_UART0_BASE, ADM5120_UART_LCR_L) =
ADM5120_UART_BAUD115200 & 0xff;
ADM5120_UART_REG(ADM5120_UART0_BASE, ADM5120_UART_LCR_M) =
ADM5120_UART_BAUD115200 >> 8;
ADM5120_UART_REG(ADM5120_UART0_BASE, ADM5120_UART_LCR_H) =
ADM5120_UART_W8 | ADM5120_UART_FIFO_EN;
/* Enable port */
ADM5120_UART_REG(ADM5120_UART0_BASE, ADM5120_UART_CR) =
ADM5120_UART_EN;
return 0;
}
static struct uart_driver adm5120ser_reg;
static struct console adm5120_serconsole = {
.name = "ttyS",
.write = adm5120console_write,
.device = uart_console_device,
.setup = adm5120console_setup,
.flags = CON_PRINTBUFFER,
.cflag = B115200 | CS8 | CREAD,
.index = 0,
.data = &adm5120ser_reg,
};
static int __init adm5120console_init(void)
{
register_console(&adm5120_serconsole);
return 0;
}
console_initcall(adm5120console_init);
static struct uart_port adm5120ser_ports[] = {
{
.iobase = ADM5120_UART0_BASE,
.irq = ADM5120_IRQ_UART0,
.uartclk = ADM5120_UARTCLK_FREQ,
.fifosize = 16,
.ops = &adm5120ser_ops,
.line = 0,
.flags = ASYNC_BOOT_AUTOCONF,
},
#if (CONFIG_ADM5120_NR_UARTS > 1)
{
.iobase = ADM5120_UART1_BASE,
.irq = ADM5120_IRQ_UART1,
.uartclk = ADM5120_UARTCLK_FREQ,
.fifosize = 16,
.ops = &adm5120ser_ops,
.line = 1,
.flags = ASYNC_BOOT_AUTOCONF,
},
#endif
};
static struct uart_driver adm5120ser_reg = {
.owner = THIS_MODULE,
.driver_name = "ttyS",
.dev_name = "ttyS",
.major = TTY_MAJOR,
.minor = 64,
.nr = CONFIG_ADM5120_NR_UARTS,
.cons = &adm5120_serconsole,
};
static int __init adm5120ser_init(void)
{
int ret, i;
ret = uart_register_driver(&adm5120ser_reg);
if (!ret) {
for (i = 0; i < CONFIG_ADM5120_NR_UARTS; i++)
uart_add_one_port(&adm5120ser_reg, &adm5120ser_ports[i]);
}
return ret;
}
__initcall(adm5120ser_init);

View File

@@ -82,7 +82,7 @@ static inline char *td_togglestring(u32 info)
* small: 0) header + data packets 1) just header
*/
static void __attribute__((unused))
urb_print(struct admhcd *ahcd, struct urb *urb, char *str, int small)
urb_print(struct admhcd *ahcd, struct urb *urb, char *str, int small, int status)
{
unsigned int pipe = urb->pipe;
@@ -92,7 +92,7 @@ urb_print(struct admhcd *ahcd, struct urb *urb, char *str, int small)
}
#ifndef ADMHC_VERBOSE_DEBUG
if (urb->status != 0)
if (status != 0)
#endif
admhc_dbg(ahcd, "URB-%s %p dev=%d ep=%d%s-%s flags=%x len=%d/%d "
"stat=%d\n",
@@ -105,7 +105,7 @@ urb_print(struct admhcd *ahcd, struct urb *urb, char *str, int small)
urb->transfer_flags,
urb->actual_length,
urb->transfer_buffer_length,
urb->status);
status);
#ifdef ADMHC_VERBOSE_DEBUG
if (!small) {
@@ -125,7 +125,7 @@ urb_print(struct admhcd *ahcd, struct urb *urb, char *str, int small)
urb->transfer_buffer_length: urb->actual_length;
for (i = 0; i < 16 && i < len; i++)
printk(" %02x", ((__u8 *)urb->transfer_buffer)[i]);
printk("%s stat:%d\n", i < len? "...": "", urb->status);
printk("%s stat:%d\n", i < len? "...": "", status);
}
}
#endif /* ADMHC_VERBOSE_DEBUG */

View File

@@ -45,7 +45,7 @@
#include "../core/hcd.h"
#include "../core/hub.h"
#define DRIVER_VERSION "0.16.3"
#define DRIVER_VERSION "0.24.0"
#define DRIVER_AUTHOR "Gabor Juhos <juhosg at openwrt.org>"
#define DRIVER_DESC "ADMtek USB 1.1 Host Controller Driver"
@@ -83,8 +83,8 @@ static void admhc_stop(struct usb_hcd *hcd);
/*
* queue up an urb for anything except the root hub
*/
static int admhc_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *ep,
struct urb *urb, gfp_t mem_flags)
static int admhc_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
gfp_t mem_flags)
{
struct admhcd *ahcd = hcd_to_admhcd(hcd);
struct ed *ed;
@@ -96,12 +96,12 @@ static int admhc_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *ep,
#ifdef ADMHC_VERBOSE_DEBUG
spin_lock_irqsave(&ahcd->lock, flags);
urb_print(ahcd, urb, "ENQEUE", usb_pipein(pipe));
urb_print(ahcd, urb, "ENQEUE", usb_pipein(pipe), -EINPROGRESS);
spin_unlock_irqrestore(&ahcd->lock, flags);
#endif
/* every endpoint has an ed, locate and maybe (re)initialize it */
ed = ed_get(ahcd, ep, urb->dev, pipe, urb->interval);
ed = ed_get(ahcd, urb->ep, urb->dev, pipe, urb->interval);
if (!ed)
return -ENOMEM;
@@ -161,22 +161,17 @@ static int admhc_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *ep,
goto fail;
}
/* in case of unlink-during-submit */
spin_lock(&urb->lock);
if (urb->status != -EINPROGRESS) {
spin_unlock(&urb->lock);
urb->hcpriv = urb_priv;
finish_urb(ahcd, urb);
ret = 0;
ret = usb_hcd_link_urb_to_ep(hcd, urb);
if (ret)
goto fail;
}
/* schedule the ed if needed */
if (ed->state == ED_IDLE) {
ret = ed_schedule(ahcd, ed);
if (ret < 0)
goto fail0;
if (ret < 0) {
usb_hcd_unlink_urb_from_ep(hcd, urb);
goto fail;
}
if (ed->type == PIPE_ISOCHRONOUS) {
u16 frame = admhc_frame_no(ahcd);
@@ -204,8 +199,6 @@ static int admhc_urb_enqueue(struct usb_hcd *hcd, struct usb_host_endpoint *ep,
admhc_dump_ed(ahcd, "admhc_urb_enqueue", urb_priv->ed, 1);
#endif
fail0:
spin_unlock(&urb->lock);
fail:
if (ret)
urb_priv_free(ahcd, urb_priv);
@@ -215,23 +208,28 @@ fail:
}
/*
* decouple the URB from the HC queues (TDs, urb_priv); it's
* already marked using urb->status. reporting is always done
* decouple the URB from the HC queues (TDs, urb_priv);
* reporting is always done
* asynchronously, and we might be dealing with an urb that's
* partially transferred, or an ED with other urbs being unlinked.
*/
static int admhc_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
static int admhc_urb_dequeue(struct usb_hcd *hcd, struct urb *urb,
int status)
{
struct admhcd *ahcd = hcd_to_admhcd(hcd);
unsigned long flags;
int ret;
spin_lock_irqsave(&ahcd->lock, flags);
#ifdef ADMHC_VERBOSE_DEBUG
urb_print(ahcd, urb, "DEQUEUE", 1);
urb_print(ahcd, urb, "DEQUEUE", 1, status);
#endif
if (HC_IS_RUNNING(hcd->state)) {
ret = usb_hcd_check_unlink_urb(hcd, urb, status);
if (ret) {
/* Do nothing */
;
} else if (HC_IS_RUNNING(hcd->state)) {
struct urb_priv *urb_priv;
/* Unless an IRQ completed the unlink while it was being
@@ -249,11 +247,11 @@ static int admhc_urb_dequeue(struct usb_hcd *hcd, struct urb *urb)
* any more ... just clean up every urb's memory.
*/
if (urb->hcpriv)
finish_urb(ahcd, urb);
finish_urb(ahcd, urb, status);
}
spin_unlock_irqrestore(&ahcd->lock, flags);
return 0;
return ret;
}
/*-------------------------------------------------------------------------*/

View File

@@ -383,9 +383,8 @@ static int admhc_restart(struct admhcd *ahcd)
ed, ed->state);
}
spin_lock(&urb->lock);
urb->status = -ESHUTDOWN;
spin_unlock(&urb->lock);
if (!urb->unlinked)
urb->unlinked = -ESHUTDOWN;
}
finish_unlinks(ahcd, 0);
spin_unlock_irq(&ahcd->lock);

View File

@@ -23,31 +23,14 @@
* PRECONDITION: ahcd lock held, irqs blocked.
*/
static void
finish_urb(struct admhcd *ahcd, struct urb *urb)
finish_urb(struct admhcd *ahcd, struct urb *urb, int status)
__releases(ahcd->lock)
__acquires(ahcd->lock)
{
urb_priv_free(ahcd, urb->hcpriv);
urb->hcpriv = NULL;
spin_lock(&urb->lock);
if (likely(urb->status == -EINPROGRESS))
urb->status = 0;
/* report short control reads right even though the data TD always
* has TD_R set. (much simpler, but creates the 1-td limit.)
*/
if (unlikely(urb->transfer_flags & URB_SHORT_NOT_OK)
&& unlikely(usb_pipecontrol(urb->pipe))
&& urb->actual_length < urb->transfer_buffer_length
&& usb_pipein(urb->pipe)
&& urb->status == 0) {
urb->status = -EREMOTEIO;
#ifdef ADMHC_VERBOSE_DEBUG
urb_print(ahcd, urb, "SHORT", usb_pipeout(urb->pipe));
#endif
}
spin_unlock(&urb->lock);
if (likely(status == -EINPROGRESS))
status = 0;
switch (usb_pipetype(urb->pipe)) {
case PIPE_ISOCHRONOUS:
@@ -59,12 +42,13 @@ __acquires(ahcd->lock)
}
#ifdef ADMHC_VERBOSE_DEBUG
urb_print(ahcd, urb, "RET", usb_pipeout (urb->pipe));
urb_print(ahcd, urb, "RET", usb_pipeout (urb->pipe), status);
#endif
/* urb->complete() can reenter this HCD */
usb_hcd_unlink_urb_from_ep(admhcd_to_hcd(ahcd), urb);
spin_unlock(&ahcd->lock);
usb_hcd_giveback_urb(admhcd_to_hcd(ahcd), urb);
usb_hcd_giveback_urb(admhcd_to_hcd(ahcd), urb, status);
spin_lock(&ahcd->lock);
}
@@ -571,9 +555,7 @@ static void td_submit_urb(struct admhcd *ahcd, struct urb *urb)
* Done List handling functions
*-------------------------------------------------------------------------*/
/* calculate transfer length/status and update the urb
* PRECONDITION: irqsafe (only for urb->status locking)
*/
/* calculate transfer length/status and update the urb */
static int td_done(struct admhcd *ahcd, struct urb *urb, struct td *td)
{
struct urb_priv *urb_priv = urb->hcpriv;
@@ -582,6 +564,7 @@ static int td_done(struct admhcd *ahcd, struct urb *urb, struct td *td)
u32 tdDBP;
int type = usb_pipetype(urb->pipe);
int cc;
int status = -EINPROGRESS;
info = hc32_to_cpup(ahcd, &td->hwINFO);
tdDBP = hc32_to_cpup(ahcd, &td->hwDBP);
@@ -596,10 +579,9 @@ static int td_done(struct admhcd *ahcd, struct urb *urb, struct td *td)
/* NOTE: assumes FC in tdINFO == 0, and that
* only the first of 0..MAXPSW psws is used.
*/
#if 0
if (tdINFO & TD_CC) /* hc didn't touch? */
return;
#endif
if (info & TD_CC) /* hc didn't touch? */
return status;
if (usb_pipeout(urb->pipe))
dlen = urb->iso_frame_desc[td->index].length;
else {
@@ -628,12 +610,9 @@ static int td_done(struct admhcd *ahcd, struct urb *urb, struct td *td)
&& !(urb->transfer_flags & URB_SHORT_NOT_OK))
cc = TD_CC_NOERROR;
if (cc != TD_CC_NOERROR && cc < TD_CC_HCD0) {
spin_lock(&urb->lock);
if (urb->status == -EINPROGRESS)
urb->status = cc_to_error[cc];
spin_unlock(&urb->lock);
}
if (cc != TD_CC_NOERROR && cc < TD_CC_HCD0)
status = cc_to_error[cc];
/* count all non-empty packets except control SETUP packet */
if ((type != PIPE_CONTROL || td->index != 0) && tdDBP != 0) {
@@ -651,15 +630,16 @@ static int td_done(struct admhcd *ahcd, struct urb *urb, struct td *td)
list_del(&td->td_list);
urb_priv->td_idx++;
return cc;
return status;
}
/*-------------------------------------------------------------------------*/
static inline struct td *
static inline void
ed_halted(struct admhcd *ahcd, struct td *td, int cc, struct td *rev)
{
struct urb *urb = td->urb;
struct urb_priv *urb_priv = urb->hcpriv;
struct ed *ed = td->ed;
struct list_head *tmp = td->td_list.next;
__hc32 toggle = ed->hwHeadP & cpu_to_hc32(ahcd, ED_C);
@@ -672,13 +652,12 @@ ed_halted(struct admhcd *ahcd, struct td *td, int cc, struct td *rev)
wmb();
ed->hwHeadP &= ~cpu_to_hc32(ahcd, ED_H);
/* put any later tds from this urb onto the donelist, after 'td',
* order won't matter here: no errors, and nothing was transferred.
* also patch the ed so it looks as if those tds completed normally.
/* Get rid of all later tds from this urb. We don't have
* to be careful: no errors and nothing was transferred.
* Also patch the ed so it looks as if those tds completed normally.
*/
while (tmp != &ed->td_list) {
struct td *next;
__hc32 info;
next = list_entry(tmp, struct td, td_list);
tmp = next->td_list.next;
@@ -693,16 +672,8 @@ ed_halted(struct admhcd *ahcd, struct td *td, int cc, struct td *rev)
* then we need to leave the control STATUS packet queued
* and clear ED_SKIP.
*/
info = next->hwINFO;
#if 0 /* FIXME */
info |= cpu_to_hc32(ahcd, TD_DONE);
#endif
info &= ~cpu_to_hc32(ahcd, TD_CC);
next->hwINFO = info;
next->next_dl_td = rev;
rev = next;
list_del(&next->td_list);
urb_priv->td_cnt++;
ed->hwHeadP = next->hwNextTD | toggle;
}
@@ -728,8 +699,6 @@ ed_halted(struct admhcd *ahcd, struct td *td, int cc, struct td *rev)
hc32_to_cpu(ahcd, td->hwINFO),
cc, cc_to_error [cc]);
}
return rev;
}
/*-------------------------------------------------------------------------*/
@@ -796,12 +765,13 @@ rescan_this:
struct urb *urb;
struct urb_priv *urb_priv;
__hc32 savebits;
int status;
td = list_entry(entry, struct td, td_list);
urb = td->urb;
urb_priv = td->urb->hcpriv;
if (urb->status == -EINPROGRESS) {
if (!urb->unlinked) {
prev = &td->hwNextTD;
continue;
}
@@ -817,12 +787,12 @@ rescan_this:
#ifdef ADMHC_VERBOSE_DEBUG
urb_print(ahcd, urb, "PARTIAL", 0);
#endif
td_done(ahcd, urb, td);
status = td_done(ahcd, urb, td);
/* if URB is done, clean up */
if (urb_priv->td_idx == urb_priv->td_cnt) {
modified = completed = 1;
finish_urb(ahcd, urb);
finish_urb(ahcd, urb, status);
}
}
if (completed && !list_empty(&ed->td_list))
@@ -920,13 +890,13 @@ static void ed_update(struct admhcd *ahcd, struct ed *ed)
struct td *td = list_entry(entry, struct td, td_list);
struct urb *urb = td->urb;
struct urb_priv *urb_priv = urb->hcpriv;
int cc;
int status;
if (hc32_to_cpup(ahcd, &td->hwINFO) & TD_OWN)
break;
/* update URB's length and status from TD */
cc = td_done(ahcd, urb, td);
status = td_done(ahcd, urb, td);
if (is_ed_halted(ahcd, ed) && is_td_halted(ahcd, ed, td))
ed_unhalt(ahcd, ed, urb);
@@ -935,7 +905,7 @@ static void ed_update(struct admhcd *ahcd, struct ed *ed)
/* If all this urb's TDs are done, call complete() */
if (urb_priv->td_idx == urb_priv->td_cnt)
finish_urb(ahcd, urb);
finish_urb(ahcd, urb, status);
/* clean schedule: unlink EDs that are no longer busy */
if (list_empty(&ed->td_list)) {