s3c2410.c 3.0 KB
Newer Older
1
/* linux/drivers/serial/s3c2410.c
L
Linus Torvalds 已提交
2
 *
3
 * Driver for Samsung S3C2410 SoC onboard UARTs.
L
Linus Torvalds 已提交
4
 *
5
 * Ben Dooks, Copyright (c) 2003-2005,2008 Simtec Electronics
6
 *	http://armlinux.simtec.co.uk/
7 8 9 10
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
L
Linus Torvalds 已提交
11 12
*/

13 14 15 16 17 18 19
#include <linux/module.h>
#include <linux/ioport.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/init.h>
#include <linux/serial_core.h>
#include <linux/serial.h>
L
Linus Torvalds 已提交
20

21
#include <asm/irq.h>
22
#include <mach/hardware.h>
L
Linus Torvalds 已提交
23

24
#include <plat/regs-serial.h>
25
#include <mach/regs-gpio.h>
L
Linus Torvalds 已提交
26

27
#include "samsung.h"
L
Linus Torvalds 已提交
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85

static int s3c2410_serial_setsource(struct uart_port *port,
				    struct s3c24xx_uart_clksrc *clk)
{
	unsigned long ucon = rd_regl(port, S3C2410_UCON);

	if (strcmp(clk->name, "uclk") == 0)
		ucon |= S3C2410_UCON_UCLK;
	else
		ucon &= ~S3C2410_UCON_UCLK;

	wr_regl(port, S3C2410_UCON, ucon);
	return 0;
}

static int s3c2410_serial_getsource(struct uart_port *port,
				    struct s3c24xx_uart_clksrc *clk)
{
	unsigned long ucon = rd_regl(port, S3C2410_UCON);

	clk->divisor = 1;
	clk->name = (ucon & S3C2410_UCON_UCLK) ? "uclk" : "pclk";

	return 0;
}

static int s3c2410_serial_resetport(struct uart_port *port,
				    struct s3c2410_uartcfg *cfg)
{
	dbg("s3c2410_serial_resetport: port=%p (%08lx), cfg=%p\n",
	    port, port->mapbase, cfg);

	wr_regl(port, S3C2410_UCON,  cfg->ucon);
	wr_regl(port, S3C2410_ULCON, cfg->ulcon);

	/* reset both fifos */

	wr_regl(port, S3C2410_UFCON, cfg->ufcon | S3C2410_UFCON_RESETBOTH);
	wr_regl(port, S3C2410_UFCON, cfg->ufcon);

	return 0;
}

static struct s3c24xx_uart_info s3c2410_uart_inf = {
	.name		= "Samsung S3C2410 UART",
	.type		= PORT_S3C2410,
	.fifosize	= 16,
	.rx_fifomask	= S3C2410_UFSTAT_RXMASK,
	.rx_fifoshift	= S3C2410_UFSTAT_RXSHIFT,
	.rx_fifofull	= S3C2410_UFSTAT_RXFULL,
	.tx_fifofull	= S3C2410_UFSTAT_TXFULL,
	.tx_fifomask	= S3C2410_UFSTAT_TXMASK,
	.tx_fifoshift	= S3C2410_UFSTAT_TXSHIFT,
	.get_clksrc	= s3c2410_serial_getsource,
	.set_clksrc	= s3c2410_serial_setsource,
	.reset_port	= s3c2410_serial_resetport,
};

86
static int s3c2410_serial_probe(struct platform_device *dev)
L
Linus Torvalds 已提交
87 88 89 90
{
	return s3c24xx_serial_probe(dev, &s3c2410_uart_inf);
}

91
static struct platform_driver s3c2410_serial_driver = {
L
Linus Torvalds 已提交
92
	.probe		= s3c2410_serial_probe,
93
	.remove		= __devexit_p(s3c24xx_serial_remove),
94 95 96 97
	.driver		= {
		.name	= "s3c2410-uart",
		.owner	= THIS_MODULE,
	},
L
Linus Torvalds 已提交
98 99
};

100
s3c24xx_console_init(&s3c2410_serial_driver, &s3c2410_uart_inf);
101 102

static int __init s3c2410_serial_init(void)
L
Linus Torvalds 已提交
103
{
104
	return s3c24xx_serial_init(&s3c2410_serial_driver, &s3c2410_uart_inf);
L
Linus Torvalds 已提交
105 106
}

107
static void __exit s3c2410_serial_exit(void)
L
Linus Torvalds 已提交
108
{
109
	platform_driver_unregister(&s3c2410_serial_driver);
L
Linus Torvalds 已提交
110 111
}

112 113
module_init(s3c2410_serial_init);
module_exit(s3c2410_serial_exit);
L
Linus Torvalds 已提交
114

115
MODULE_LICENSE("GPL v2");
L
Linus Torvalds 已提交
116
MODULE_AUTHOR("Ben Dooks <ben@simtec.co.uk>");
117
MODULE_DESCRIPTION("Samsung S3C2410 SoC Serial port driver");
118
MODULE_ALIAS("platform:s3c2410-uart");