Jovi Zhang | 99edb3d | 2011-03-30 05:30:41 -0400 | [diff] [blame] | 1 | /* |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 2 | * Driver for Samsung SoC onboard UARTs. |
| 3 | * |
Ben Dooks | ccae941 | 2009-11-13 22:54:14 +0000 | [diff] [blame] | 4 | * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 5 | * 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 | |
| 12 | struct 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 Dooks | 090f848 | 2008-12-12 00:24:21 +0000 | [diff] [blame] | 23 | /* uart port features */ |
| 24 | |
| 25 | unsigned int has_divslot:1; |
| 26 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 27 | /* 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 | |
| 36 | struct s3c24xx_uart_port { |
| 37 | unsigned char rx_claimed; |
| 38 | unsigned char tx_claimed; |
Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 39 | unsigned int pm_level; |
| 40 | unsigned long baudclk_rate; |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 41 | |
Ben Dooks | b73c289c | 2008-10-21 14:07:04 +0100 | [diff] [blame] | 42 | unsigned int rx_irq; |
| 43 | unsigned int tx_irq; |
| 44 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 45 | 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 Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 50 | |
| 51 | #ifdef CONFIG_CPU_FREQ |
| 52 | struct notifier_block freq_transition; |
| 53 | #endif |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 54 | }; |
| 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)) |
| 64 | |
| 65 | #define rd_regb(port, reg) (__raw_readb(portaddr(port, reg))) |
| 66 | #define rd_regl(port, reg) (__raw_readl(portaddr(port, reg))) |
| 67 | |
| 68 | #define wr_regb(port, reg, val) __raw_writeb(val, portaddr(port, reg)) |
| 69 | #define wr_regl(port, reg, val) __raw_writel(val, portaddr(port, reg)) |
| 70 | |
| 71 | extern int s3c24xx_serial_probe(struct platform_device *dev, |
| 72 | struct s3c24xx_uart_info *uart); |
| 73 | |
Peter Korsgaard | 90ceb964 | 2009-06-22 18:42:49 +0100 | [diff] [blame] | 74 | extern int __devexit s3c24xx_serial_remove(struct platform_device *dev); |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 75 | |
| 76 | extern int s3c24xx_serial_initconsole(struct platform_driver *drv, |
Thomas Abraham | 51fe522 | 2010-01-14 15:05:38 +0900 | [diff] [blame] | 77 | struct s3c24xx_uart_info **uart); |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 78 | |
| 79 | extern int s3c24xx_serial_init(struct platform_driver *drv, |
| 80 | struct s3c24xx_uart_info *info); |
| 81 | |
| 82 | #ifdef CONFIG_SERIAL_SAMSUNG_CONSOLE |
| 83 | |
Thomas Abraham | 51fe522 | 2010-01-14 15:05:38 +0900 | [diff] [blame] | 84 | #define s3c24xx_console_init(__drv, __inf) \ |
| 85 | static int __init s3c_serial_console_init(void) \ |
| 86 | { \ |
| 87 | struct s3c24xx_uart_info *uinfo[CONFIG_SERIAL_SAMSUNG_UARTS]; \ |
| 88 | int i; \ |
| 89 | \ |
| 90 | for (i = 0; i < CONFIG_SERIAL_SAMSUNG_UARTS; i++) \ |
| 91 | uinfo[i] = __inf; \ |
| 92 | return s3c24xx_serial_initconsole(__drv, uinfo); \ |
| 93 | } \ |
| 94 | \ |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 95 | console_initcall(s3c_serial_console_init) |
| 96 | |
| 97 | #else |
| 98 | #define s3c24xx_console_init(drv, inf) extern void no_console(void) |
| 99 | #endif |
| 100 | |
| 101 | #ifdef CONFIG_SERIAL_SAMSUNG_DEBUG |
| 102 | |
| 103 | extern void printascii(const char *); |
| 104 | |
| 105 | static void dbg(const char *fmt, ...) |
| 106 | { |
| 107 | va_list va; |
| 108 | char buff[256]; |
| 109 | |
| 110 | va_start(va, fmt); |
| 111 | vsprintf(buff, fmt, va); |
| 112 | va_end(va); |
| 113 | |
| 114 | printascii(buff); |
| 115 | } |
| 116 | |
| 117 | #else |
| 118 | #define dbg(x...) do { } while (0) |
| 119 | #endif |