| Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 1 | /* linux/drivers/serial/samsung.h | 
|  | 2 | * | 
|  | 3 | * Driver for Samsung SoC onboard UARTs. | 
|  | 4 | * | 
| Ben Dooks | ccae941 | 2009-11-13 22:54:14 +0000 | [diff] [blame] | 5 | * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics | 
| Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 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 |  | 
|  | 13 | struct 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 Dooks | 090f848 | 2008-12-12 00:24:21 +0000 | [diff] [blame] | 24 | /* uart port features */ | 
|  | 25 |  | 
|  | 26 | unsigned int		has_divslot:1; | 
|  | 27 |  | 
| Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 28 | /* 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 |  | 
|  | 37 | struct s3c24xx_uart_port { | 
|  | 38 | unsigned char			rx_claimed; | 
|  | 39 | unsigned char			tx_claimed; | 
| Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 40 | unsigned int			pm_level; | 
|  | 41 | unsigned long			baudclk_rate; | 
| Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 42 |  | 
| Ben Dooks | b73c289c | 2008-10-21 14:07:04 +0100 | [diff] [blame] | 43 | unsigned int			rx_irq; | 
|  | 44 | unsigned int			tx_irq; | 
|  | 45 |  | 
| Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 46 | 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 Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 51 |  | 
|  | 52 | #ifdef CONFIG_CPU_FREQ | 
|  | 53 | struct notifier_block		freq_transition; | 
|  | 54 | #endif | 
| Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 55 | }; | 
|  | 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 |  | 
|  | 72 | extern int s3c24xx_serial_probe(struct platform_device *dev, | 
|  | 73 | struct s3c24xx_uart_info *uart); | 
|  | 74 |  | 
| Peter Korsgaard | 90ceb964 | 2009-06-22 18:42:49 +0100 | [diff] [blame] | 75 | extern int __devexit s3c24xx_serial_remove(struct platform_device *dev); | 
| Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 76 |  | 
|  | 77 | extern int s3c24xx_serial_initconsole(struct platform_driver *drv, | 
| Thomas Abraham | 51fe522 | 2010-01-14 15:05:38 +0900 | [diff] [blame] | 78 | struct s3c24xx_uart_info **uart); | 
| Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 79 |  | 
|  | 80 | extern int s3c24xx_serial_init(struct platform_driver *drv, | 
|  | 81 | struct s3c24xx_uart_info *info); | 
|  | 82 |  | 
|  | 83 | #ifdef CONFIG_SERIAL_SAMSUNG_CONSOLE | 
|  | 84 |  | 
| Thomas Abraham | 51fe522 | 2010-01-14 15:05:38 +0900 | [diff] [blame] | 85 | #define s3c24xx_console_init(__drv, __inf)				\ | 
|  | 86 | static 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 Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 96 | console_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 |  | 
|  | 104 | extern void printascii(const char *); | 
|  | 105 |  | 
|  | 106 | static 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 |