blob: 8e87b788e5c6a62d65c2cf727008736486401160 [file] [log] [blame]
Jovi Zhang99edb3d2011-03-30 05:30:41 -04001/*
Ben Dooksb4975492008-07-03 12:32:51 +01002 * Driver for Samsung SoC onboard UARTs.
3 *
Ben Dooksccae9412009-11-13 22:54:14 +00004 * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics
Ben Dooksb4975492008-07-03 12:32:51 +01005 * http://armlinux.simtec.co.uk/
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License version 2 as
9 * published by the Free Software Foundation.
10*/
11
12struct s3c24xx_uart_info {
13 char *name;
14 unsigned int type;
15 unsigned int fifosize;
16 unsigned long rx_fifomask;
17 unsigned long rx_fifoshift;
18 unsigned long rx_fifofull;
19 unsigned long tx_fifomask;
20 unsigned long tx_fifoshift;
21 unsigned long tx_fifofull;
22
Ben Dooks090f8482008-12-12 00:24:21 +000023 /* uart port features */
24
25 unsigned int has_divslot:1;
26
Ben Dooksb4975492008-07-03 12:32:51 +010027 /* clock source control */
28
29 int (*get_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk);
30 int (*set_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk);
31
32 /* uart controls */
33 int (*reset_port)(struct uart_port *, struct s3c2410_uartcfg *);
34};
35
36struct s3c24xx_uart_port {
37 unsigned char rx_claimed;
38 unsigned char tx_claimed;
Ben Dooks30555472008-10-21 14:06:36 +010039 unsigned int pm_level;
40 unsigned long baudclk_rate;
Ben Dooksb4975492008-07-03 12:32:51 +010041
Ben Dooksb73c289c2008-10-21 14:07:04 +010042 unsigned int rx_irq;
43 unsigned int tx_irq;
44
Ben Dooksb4975492008-07-03 12:32:51 +010045 struct s3c24xx_uart_info *info;
46 struct s3c24xx_uart_clksrc *clksrc;
47 struct clk *clk;
48 struct clk *baudclk;
49 struct uart_port port;
Ben Dooks30555472008-10-21 14:06:36 +010050
51#ifdef CONFIG_CPU_FREQ
52 struct notifier_block freq_transition;
53#endif
Ben Dooksb4975492008-07-03 12:32:51 +010054};
55
56/* conversion functions */
57
58#define s3c24xx_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev)
59#define s3c24xx_dev_to_cfg(__dev) (struct s3c2410_uartcfg *)((__dev)->platform_data)
60
61/* register access controls */
62
63#define portaddr(port, reg) ((port)->membase + (reg))
Thomas Abraham88bb4ea2011-08-10 15:51:19 +053064#define portaddrl(port, reg) ((unsigned long *)((port)->membase + (reg)))
Ben Dooksb4975492008-07-03 12:32:51 +010065
66#define rd_regb(port, reg) (__raw_readb(portaddr(port, reg)))
67#define rd_regl(port, reg) (__raw_readl(portaddr(port, reg)))
68
69#define wr_regb(port, reg, val) __raw_writeb(val, portaddr(port, reg))
70#define wr_regl(port, reg, val) __raw_writel(val, portaddr(port, reg))
71
72extern int s3c24xx_serial_probe(struct platform_device *dev,
73 struct s3c24xx_uart_info *uart);
74
Peter Korsgaard90ceb9642009-06-22 18:42:49 +010075extern int __devexit s3c24xx_serial_remove(struct platform_device *dev);
Ben Dooksb4975492008-07-03 12:32:51 +010076
77extern int s3c24xx_serial_initconsole(struct platform_driver *drv,
Thomas Abraham51fe5222010-01-14 15:05:38 +090078 struct s3c24xx_uart_info **uart);
Ben Dooksb4975492008-07-03 12:32:51 +010079
80extern int s3c24xx_serial_init(struct platform_driver *drv,
81 struct s3c24xx_uart_info *info);
82
Ben Dooksb4975492008-07-03 12:32:51 +010083#ifdef CONFIG_SERIAL_SAMSUNG_DEBUG
84
85extern void printascii(const char *);
86
87static void dbg(const char *fmt, ...)
88{
89 va_list va;
90 char buff[256];
91
92 va_start(va, fmt);
93 vsprintf(buff, fmt, va);
94 va_end(va);
95
96 printascii(buff);
97}
98
99#else
100#define dbg(x...) do { } while (0)
101#endif