blob: d3fe315969f6d628c2f8ff9fca95ebe5cf2345ee [file] [log] [blame]
Ben Dooksb4975492008-07-03 12:32:51 +01001/* linux/drivers/serial/samsung.h
2 *
3 * Driver for Samsung SoC onboard UARTs.
4 *
5 * Ben Dooks, Copyright (c) 2003-2005,2008 Simtec Electronics
6 * http://armlinux.simtec.co.uk/
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
11*/
12
13struct s3c24xx_uart_info {
14 char *name;
15 unsigned int type;
16 unsigned int fifosize;
17 unsigned long rx_fifomask;
18 unsigned long rx_fifoshift;
19 unsigned long rx_fifofull;
20 unsigned long tx_fifomask;
21 unsigned long tx_fifoshift;
22 unsigned long tx_fifofull;
23
Ben Dooks090f8482008-12-12 00:24:21 +000024 /* uart port features */
25
26 unsigned int has_divslot:1;
27
Ben Dooksb4975492008-07-03 12:32:51 +010028 /* clock source control */
29
30 int (*get_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk);
31 int (*set_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk);
32
33 /* uart controls */
34 int (*reset_port)(struct uart_port *, struct s3c2410_uartcfg *);
35};
36
37struct s3c24xx_uart_port {
38 unsigned char rx_claimed;
39 unsigned char tx_claimed;
Ben Dooks30555472008-10-21 14:06:36 +010040 unsigned int pm_level;
41 unsigned long baudclk_rate;
Ben Dooksb4975492008-07-03 12:32:51 +010042
Ben Dooksb73c289c2008-10-21 14:07:04 +010043 unsigned int rx_irq;
44 unsigned int tx_irq;
45
Ben Dooksb4975492008-07-03 12:32:51 +010046 struct s3c24xx_uart_info *info;
47 struct s3c24xx_uart_clksrc *clksrc;
48 struct clk *clk;
49 struct clk *baudclk;
50 struct uart_port port;
Ben Dooks30555472008-10-21 14:06:36 +010051
52#ifdef CONFIG_CPU_FREQ
53 struct notifier_block freq_transition;
54#endif
Ben Dooksb4975492008-07-03 12:32:51 +010055};
56
57/* conversion functions */
58
59#define s3c24xx_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev)
60#define s3c24xx_dev_to_cfg(__dev) (struct s3c2410_uartcfg *)((__dev)->platform_data)
61
62/* register access controls */
63
64#define portaddr(port, reg) ((port)->membase + (reg))
65
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,
78 struct s3c24xx_uart_info *uart);
79
80extern int s3c24xx_serial_init(struct platform_driver *drv,
81 struct s3c24xx_uart_info *info);
82
83#ifdef CONFIG_SERIAL_SAMSUNG_CONSOLE
84
85#define s3c24xx_console_init(__drv, __inf) \
86static int __init s3c_serial_console_init(void) \
87{ \
88 return s3c24xx_serial_initconsole(__drv, __inf); \
89} \
90 \
91console_initcall(s3c_serial_console_init)
92
93#else
94#define s3c24xx_console_init(drv, inf) extern void no_console(void)
95#endif
96
97#ifdef CONFIG_SERIAL_SAMSUNG_DEBUG
98
99extern void printascii(const char *);
100
101static void dbg(const char *fmt, ...)
102{
103 va_list va;
104 char buff[256];
105
106 va_start(va, fmt);
107 vsprintf(buff, fmt, va);
108 va_end(va);
109
110 printascii(buff);
111}
112
113#else
114#define dbg(x...) do { } while (0)
115#endif