分类: LINUX
2010-01-05 14:07:28
/* module initialisation code */
{
int ret;
ret = uart_register_driver(&s
if (ret < 0) {
printk(KERN_ERR "failed to register UART driver\n");
return -1;
}
2/ *
s
s
s
s
return 0;
}
.owner = THIS_MODULE,
.dev_name = "s
.nr = 3,
.cons = S
.driver_name = S
.major = S
.minor = S
};
{
struct tty_driver *normal = NULL;
int i, retval;
BUG_ON(drv->state);
/*
* Maybe we should be using a slab cache for this, especially if
* we have a large number of ports to handle.
*/
drv->state = kzalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL);
retval = -ENOMEM;
if (!drv->state)
goto out;
normal = alloc_tty_driver(drv->nr);
if (!normal)
goto out;
drv->tty_driver = normal;
normal->owner = drv->owner;
normal->driver_name = drv->driver_name;
normal->name = drv->dev_name;
normal->major = drv->major;
normal->minor_start = drv->minor;
normal->type = TTY_DRIVER_TYPE_SERIAL;
normal->subtype = SERIAL_TYPE_NORMAL;
normal->init_termios = tty_std_termios;
normal->init_termios.c_cflag = B9600 | CS8 | CREAD | HUPCL | CLOCAL;
normal->init_termios.c_ispeed = normal->init_termios.c_ospeed = 9600;
normal->flags = TTY_DRIVER_REAL_RAW | TTY_DRIVER_DYNAMIC_DEV;
normal->driver_state = drv;
tty_set_operations(normal, &uart_ops);
/*
* Initialise the UART state(s).
*/
for (i = 0; i < drv->nr; i++) {
struct uart_state *state = drv->state + i;
state->close_delay = 500; /* .5 seconds */
state->closing_wait = 30000; /* 30 seconds */
mutex_init(&state->mutex);
}
retval = tty_register_driver(normal);
out:
if (retval < 0) {
put_tty_driver(normal);
kfree(drv->state);
}
return retval;
}
.name = "Samsung S
.type = PORT_S
.fifosize = 64,
.rx_fifomask = S
.rx_fifoshift = S
.rx_fifofull = S
.tx_fifofull = S
.tx_fifomask = S
.tx_fifoshift = S
.get_clksrc = s
.set_clksrc = s
.reset_port = s
};
/* device management */
{
dbg("s
return s
}
.probe = s
.remove = s
.suspend = s
.resume = s
.driver = {
.name = "s
.owner = THIS_MODULE,
},
};
{
return s
}
struct s
{
dbg("s
return platform_driver_register(drv);
}
{
dbg("s
return s
}
[0] = {
.port = {
.lock = __SPIN_LOCK_UNLOCKED(s
.iotype = UPIO_MEM,
.irq = IRQ_S3CUART_RX0,
.uartclk = 0,
.fifosize = 16,
.ops = &s
.flags = UPF_BOOT_AUTOCONF,
.line = 0,
}
},
[1] = {
.port = {
.lock = __SPIN_LOCK_UNLOCKED(s
.iotype = UPIO_MEM,
.irq = IRQ_S3CUART_RX1,
.uartclk = 0,
.fifosize = 16,
.ops = &s
.flags = UPF_BOOT_AUTOCONF,
.line = 1,
}
},
#if NR_PORTS > 2
[2] = {
.port = {
.lock = __SPIN_LOCK_UNLOCKED(s
.iotype = UPIO_MEM,
.irq = IRQ_S3CUART_RX2,
.uartclk = 0,
.fifosize = 16,
.ops = &s
.flags = UPF_BOOT_AUTOCONF,
.line = 2,
}
}
#endif
};
struct s
{
struct s
return (info->reset_port)(port, cfg);
}
/* s
*
* initialise a single serial port from the platform device given
*/
struct s
struct platform_device *platdev)
{
struct uart_port *port = &ourport->port;
struct s
struct resource *res;
dbg("s
if (platdev == NULL)
return -ENODEV;
cfg = s
if (port->mapbase != 0)
return 0;
if (cfg->hwport > 3)
return -EINVAL;
/* setup info for port */
port->dev = &platdev->dev;
ourport->info = info;
/* copy the info in from provided structure */
ourport->port.fifosize = info->fifosize;
dbg("s
port->uartclk = 1;
if (cfg->uart_flags & UPF_CONS_FLOW) {
dbg("s
port->flags |= UPF_CONS_FLOW;
}
/* sort our the physical and virtual addresses for each UART */
res = platform_get_resource(platdev, IORESOURCE_MEM, 0);
if (res == NULL) {
printk(KERN_ERR "failed to find memory resource for uart\n");
return -EINVAL;
}
dbg("resource %p (%lx..%lx)\n", res, res->start, res->end);
port->mapbase = res->start;
port->membase = S
port->irq = platform_get_irq(platdev, 0);
if (port->irq < 0)
port->irq = 0;
ourport->clk = clk_get(&platdev->dev, "uart");
dbg("port: map=%08x, mem=%08x, irq=%d, clock=%ld\n",
port->mapbase, port->membase, port->irq, port->uartclk);
/* reset the fifos (and setup the uart) */
s
return 0;
}
static int probe_index = 0;
struct s
{
struct s
int ret;
dbg("s
ourport = &s
probe_index++;
dbg("%s: initialising port %p...\n", __FUNCTION__, ourport);
ret = s
if (ret < 0)
goto probe_err;
dbg("%s: adding port\n", __FUNCTION__);
uart_add_one_port(&s
platform_set_drvdata(dev, &ourport->port);
return 0;
probe_err:
return ret;
}