blob: 0ac06a07d25ffd4b41010bcba9448588d1fa6e19 [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 *
Ben Dooksccae9412009-11-13 22:54:14 +00005 * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics
Ben Dooksb4975492008-07-03 12:32:51 +01006 * 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 Dooksb73c2892008-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 Korsgaard90ceb962009-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
83#ifdef CONFIG_SERIAL_SAMSUNG_CONSOLE
84
Thomas Abraham51fe5222010-01-14 15:05:38 +090085#define s3c24xx_console_init(__drv, __inf) \
86static int __init s3c_serial_console_init(void) \
87{ \
88 struct s3c24xx_uart_info *uinfo[CONFIG_SERIAL_SAMSUNG_UARTS]; \
89 int i; \
90 \
91 for (i = 0; i < CONFIG_SERIAL_SAMSUNG_UARTS; i++) \
92 uinfo[i] = __inf; \
93 return s3c24xx_serial_initconsole(__drv, uinfo); \
94} \
95 \
Ben Dooksb4975492008-07-03 12:32:51 +010096console_initcall(s3c_serial_console_init)
97
98#else
99#define s3c24xx_console_init(drv, inf) extern void no_console(void)
100#endif
101
102#ifdef CONFIG_SERIAL_SAMSUNG_DEBUG
103
104extern void printascii(const char *);
105
106static void dbg(const char *fmt, ...)
107{
108 va_list va;
109 char buff[256];
110
111 va_start(va, fmt);
112 vsprintf(buff, fmt, va);
113 va_end(va);
114
115 printascii(buff);
116}
117
118#else
119#define dbg(x...) do { } while (0)
120#endif