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; |
Thomas Abraham | 5f5a7a5 | 2011-10-24 11:47:46 +0200 | [diff] [blame] | 22 | unsigned int def_clk_sel; |
| 23 | unsigned long num_clks; |
| 24 | unsigned long clksel_mask; |
| 25 | unsigned long clksel_shift; |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 26 | |
Ben Dooks | 090f848 | 2008-12-12 00:24:21 +0000 | [diff] [blame] | 27 | /* uart port features */ |
| 28 | |
| 29 | unsigned int has_divslot:1; |
| 30 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 31 | /* uart controls */ |
| 32 | int (*reset_port)(struct uart_port *, struct s3c2410_uartcfg *); |
| 33 | }; |
| 34 | |
Thomas Abraham | da12150 | 2011-11-02 19:23:25 +0900 | [diff] [blame] | 35 | struct s3c24xx_serial_drv_data { |
| 36 | struct s3c24xx_uart_info *info; |
| 37 | struct s3c2410_uartcfg *def_cfg; |
| 38 | unsigned int fifosize[CONFIG_SERIAL_SAMSUNG_UARTS]; |
| 39 | }; |
| 40 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 41 | struct s3c24xx_uart_port { |
| 42 | unsigned char rx_claimed; |
| 43 | unsigned char tx_claimed; |
Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 44 | unsigned int pm_level; |
| 45 | unsigned long baudclk_rate; |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 46 | |
Ben Dooks | b73c289 | 2008-10-21 14:07:04 +0100 | [diff] [blame] | 47 | unsigned int rx_irq; |
| 48 | unsigned int tx_irq; |
| 49 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 50 | struct s3c24xx_uart_info *info; |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 51 | struct clk *clk; |
| 52 | struct clk *baudclk; |
| 53 | struct uart_port port; |
Thomas Abraham | da12150 | 2011-11-02 19:23:25 +0900 | [diff] [blame] | 54 | struct s3c24xx_serial_drv_data *drv_data; |
Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 55 | |
Thomas Abraham | 4d84e97 | 2011-10-24 11:47:25 +0200 | [diff] [blame] | 56 | /* reference to platform data */ |
| 57 | struct s3c2410_uartcfg *cfg; |
| 58 | |
Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 59 | #ifdef CONFIG_CPU_FREQ |
| 60 | struct notifier_block freq_transition; |
| 61 | #endif |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 62 | }; |
| 63 | |
| 64 | /* conversion functions */ |
| 65 | |
| 66 | #define s3c24xx_dev_to_port(__dev) (struct uart_port *)dev_get_drvdata(__dev) |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 67 | |
| 68 | /* register access controls */ |
| 69 | |
| 70 | #define portaddr(port, reg) ((port)->membase + (reg)) |
Thomas Abraham | 88bb4ea | 2011-08-10 15:51:19 +0530 | [diff] [blame] | 71 | #define portaddrl(port, reg) ((unsigned long *)((port)->membase + (reg))) |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 72 | |
| 73 | #define rd_regb(port, reg) (__raw_readb(portaddr(port, reg))) |
| 74 | #define rd_regl(port, reg) (__raw_readl(portaddr(port, reg))) |
| 75 | |
| 76 | #define wr_regb(port, reg, val) __raw_writeb(val, portaddr(port, reg)) |
| 77 | #define wr_regl(port, reg, val) __raw_writel(val, portaddr(port, reg)) |
| 78 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 79 | #ifdef CONFIG_SERIAL_SAMSUNG_DEBUG |
| 80 | |
| 81 | extern void printascii(const char *); |
| 82 | |
| 83 | static void dbg(const char *fmt, ...) |
| 84 | { |
| 85 | va_list va; |
| 86 | char buff[256]; |
| 87 | |
| 88 | va_start(va, fmt); |
| 89 | vsprintf(buff, fmt, va); |
| 90 | va_end(va); |
| 91 | |
| 92 | printascii(buff); |
| 93 | } |
| 94 | |
| 95 | #else |
| 96 | #define dbg(x...) do { } while (0) |
| 97 | #endif |