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 | |
| 24 | /* clock source control */ |
| 25 | |
| 26 | int (*get_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk); |
| 27 | int (*set_clksrc)(struct uart_port *, struct s3c24xx_uart_clksrc *clk); |
| 28 | |
| 29 | /* uart controls */ |
| 30 | int (*reset_port)(struct uart_port *, struct s3c2410_uartcfg *); |
| 31 | }; |
| 32 | |
| 33 | struct s3c24xx_uart_port { |
| 34 | unsigned char rx_claimed; |
| 35 | unsigned char tx_claimed; |
Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame^] | 36 | unsigned int pm_level; |
| 37 | unsigned long baudclk_rate; |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 38 | |
| 39 | struct s3c24xx_uart_info *info; |
| 40 | struct s3c24xx_uart_clksrc *clksrc; |
| 41 | struct clk *clk; |
| 42 | struct clk *baudclk; |
| 43 | struct uart_port port; |
Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame^] | 44 | |
| 45 | #ifdef CONFIG_CPU_FREQ |
| 46 | struct notifier_block freq_transition; |
| 47 | #endif |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 48 | }; |
| 49 | |
| 50 | /* conversion functions */ |
| 51 | |
| 52 | #define s3c24xx_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev) |
| 53 | #define s3c24xx_dev_to_cfg(__dev) (struct s3c2410_uartcfg *)((__dev)->platform_data) |
| 54 | |
| 55 | /* register access controls */ |
| 56 | |
| 57 | #define portaddr(port, reg) ((port)->membase + (reg)) |
| 58 | |
| 59 | #define rd_regb(port, reg) (__raw_readb(portaddr(port, reg))) |
| 60 | #define rd_regl(port, reg) (__raw_readl(portaddr(port, reg))) |
| 61 | |
| 62 | #define wr_regb(port, reg, val) __raw_writeb(val, portaddr(port, reg)) |
| 63 | #define wr_regl(port, reg, val) __raw_writel(val, portaddr(port, reg)) |
| 64 | |
| 65 | extern int s3c24xx_serial_probe(struct platform_device *dev, |
| 66 | struct s3c24xx_uart_info *uart); |
| 67 | |
| 68 | extern int s3c24xx_serial_remove(struct platform_device *dev); |
| 69 | |
| 70 | extern int s3c24xx_serial_initconsole(struct platform_driver *drv, |
| 71 | struct s3c24xx_uart_info *uart); |
| 72 | |
| 73 | extern int s3c24xx_serial_init(struct platform_driver *drv, |
| 74 | struct s3c24xx_uart_info *info); |
| 75 | |
| 76 | #ifdef CONFIG_SERIAL_SAMSUNG_CONSOLE |
| 77 | |
| 78 | #define s3c24xx_console_init(__drv, __inf) \ |
| 79 | static int __init s3c_serial_console_init(void) \ |
| 80 | { \ |
| 81 | return s3c24xx_serial_initconsole(__drv, __inf); \ |
| 82 | } \ |
| 83 | \ |
| 84 | console_initcall(s3c_serial_console_init) |
| 85 | |
| 86 | #else |
| 87 | #define s3c24xx_console_init(drv, inf) extern void no_console(void) |
| 88 | #endif |
| 89 | |
| 90 | #ifdef CONFIG_SERIAL_SAMSUNG_DEBUG |
| 91 | |
| 92 | extern void printascii(const char *); |
| 93 | |
| 94 | static void dbg(const char *fmt, ...) |
| 95 | { |
| 96 | va_list va; |
| 97 | char buff[256]; |
| 98 | |
| 99 | va_start(va, fmt); |
| 100 | vsprintf(buff, fmt, va); |
| 101 | va_end(va); |
| 102 | |
| 103 | printascii(buff); |
| 104 | } |
| 105 | |
| 106 | #else |
| 107 | #define dbg(x...) do { } while (0) |
| 108 | #endif |