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 | * |
| 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 | |
| 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 | b73c289 | 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 | 90ceb96 | 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, |
| 78 | struct s3c24xx_uart_info *uart); |
| 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 | |
| 85 | #define s3c24xx_console_init(__drv, __inf) \ |
| 86 | static int __init s3c_serial_console_init(void) \ |
| 87 | { \ |
| 88 | return s3c24xx_serial_initconsole(__drv, __inf); \ |
| 89 | } \ |
| 90 | \ |
| 91 | console_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 | |
| 99 | extern void printascii(const char *); |
| 100 | |
| 101 | static 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 |