Joe Perches | e4ac92d | 2014-05-20 14:05:50 -0700 | [diff] [blame] | 1 | #ifndef __SAMSUNG_H |
| 2 | #define __SAMSUNG_H |
| 3 | |
Jovi Zhang | 99edb3d | 2011-03-30 05:30:41 -0400 | [diff] [blame] | 4 | /* |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 5 | * Driver for Samsung SoC onboard UARTs. |
| 6 | * |
Ben Dooks | ccae941 | 2009-11-13 22:54:14 +0000 | [diff] [blame] | 7 | * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 8 | * http://armlinux.simtec.co.uk/ |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify |
| 11 | * it under the terms of the GNU General Public License version 2 as |
| 12 | * published by the Free Software Foundation. |
| 13 | */ |
| 14 | |
Robert Baldyga | 7bb6b2f | 2014-12-10 12:49:22 +0100 | [diff] [blame] | 15 | #include <linux/dmaengine.h> |
| 16 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 17 | struct s3c24xx_uart_info { |
| 18 | char *name; |
| 19 | unsigned int type; |
| 20 | unsigned int fifosize; |
| 21 | unsigned long rx_fifomask; |
| 22 | unsigned long rx_fifoshift; |
| 23 | unsigned long rx_fifofull; |
| 24 | unsigned long tx_fifomask; |
| 25 | unsigned long tx_fifoshift; |
| 26 | unsigned long tx_fifofull; |
Thomas Abraham | 5f5a7a5 | 2011-10-24 11:47:46 +0200 | [diff] [blame] | 27 | unsigned int def_clk_sel; |
| 28 | unsigned long num_clks; |
| 29 | unsigned long clksel_mask; |
| 30 | unsigned long clksel_shift; |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 31 | |
Ben Dooks | 090f848 | 2008-12-12 00:24:21 +0000 | [diff] [blame] | 32 | /* uart port features */ |
| 33 | |
| 34 | unsigned int has_divslot:1; |
| 35 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 36 | /* uart controls */ |
| 37 | int (*reset_port)(struct uart_port *, struct s3c2410_uartcfg *); |
| 38 | }; |
| 39 | |
Thomas Abraham | da12150 | 2011-11-02 19:23:25 +0900 | [diff] [blame] | 40 | struct s3c24xx_serial_drv_data { |
| 41 | struct s3c24xx_uart_info *info; |
| 42 | struct s3c2410_uartcfg *def_cfg; |
| 43 | unsigned int fifosize[CONFIG_SERIAL_SAMSUNG_UARTS]; |
| 44 | }; |
| 45 | |
Robert Baldyga | 7bb6b2f | 2014-12-10 12:49:22 +0100 | [diff] [blame] | 46 | struct s3c24xx_uart_dma { |
| 47 | dma_filter_fn fn; |
| 48 | void *rx_param; |
| 49 | void *tx_param; |
| 50 | |
| 51 | unsigned int rx_chan_id; |
| 52 | unsigned int tx_chan_id; |
| 53 | |
| 54 | struct dma_slave_config rx_conf; |
| 55 | struct dma_slave_config tx_conf; |
| 56 | |
| 57 | struct dma_chan *rx_chan; |
| 58 | struct dma_chan *tx_chan; |
| 59 | |
| 60 | dma_addr_t rx_addr; |
| 61 | dma_addr_t tx_addr; |
| 62 | |
| 63 | dma_cookie_t rx_cookie; |
| 64 | dma_cookie_t tx_cookie; |
| 65 | |
| 66 | char *rx_buf; |
| 67 | |
| 68 | dma_addr_t tx_transfer_addr; |
| 69 | |
| 70 | size_t rx_size; |
| 71 | size_t tx_size; |
| 72 | |
| 73 | struct dma_async_tx_descriptor *tx_desc; |
| 74 | struct dma_async_tx_descriptor *rx_desc; |
| 75 | |
| 76 | int tx_bytes_requested; |
| 77 | int rx_bytes_requested; |
| 78 | }; |
| 79 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 80 | struct s3c24xx_uart_port { |
| 81 | unsigned char rx_claimed; |
| 82 | unsigned char tx_claimed; |
Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 83 | unsigned int pm_level; |
| 84 | unsigned long baudclk_rate; |
Marek Szyprowski | 81ccb2a | 2015-07-31 10:58:27 +0200 | [diff] [blame] | 85 | unsigned int min_dma_size; |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 86 | |
Ben Dooks | b73c289c | 2008-10-21 14:07:04 +0100 | [diff] [blame] | 87 | unsigned int rx_irq; |
| 88 | unsigned int tx_irq; |
| 89 | |
Robert Baldyga | 29bef79 | 2014-12-10 12:49:26 +0100 | [diff] [blame] | 90 | unsigned int tx_in_progress; |
| 91 | unsigned int tx_mode; |
Robert Baldyga | b543c30 | 2014-12-10 12:49:27 +0100 | [diff] [blame] | 92 | unsigned int rx_mode; |
Robert Baldyga | 29bef79 | 2014-12-10 12:49:26 +0100 | [diff] [blame] | 93 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 94 | struct s3c24xx_uart_info *info; |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 95 | struct clk *clk; |
| 96 | struct clk *baudclk; |
| 97 | struct uart_port port; |
Thomas Abraham | da12150 | 2011-11-02 19:23:25 +0900 | [diff] [blame] | 98 | struct s3c24xx_serial_drv_data *drv_data; |
Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 99 | |
Thomas Abraham | 4d84e97 | 2011-10-24 11:47:25 +0200 | [diff] [blame] | 100 | /* reference to platform data */ |
| 101 | struct s3c2410_uartcfg *cfg; |
| 102 | |
Robert Baldyga | 7bb6b2f | 2014-12-10 12:49:22 +0100 | [diff] [blame] | 103 | struct s3c24xx_uart_dma *dma; |
| 104 | |
Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 105 | #ifdef CONFIG_CPU_FREQ |
| 106 | struct notifier_block freq_transition; |
| 107 | #endif |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 108 | }; |
| 109 | |
| 110 | /* conversion functions */ |
| 111 | |
Jingoo Han | d4aab20 | 2013-09-09 14:10:30 +0900 | [diff] [blame] | 112 | #define s3c24xx_dev_to_port(__dev) dev_get_drvdata(__dev) |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 113 | |
| 114 | /* register access controls */ |
| 115 | |
| 116 | #define portaddr(port, reg) ((port)->membase + (reg)) |
Jingoo Han | 9fdedf5 | 2013-08-08 17:29:48 +0900 | [diff] [blame] | 117 | #define portaddrl(port, reg) \ |
| 118 | ((unsigned long *)(unsigned long)((port)->membase + (reg))) |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 119 | |
Matthew Leach | e37697b | 2016-06-22 17:57:02 +0100 | [diff] [blame^] | 120 | #define rd_regb(port, reg) (readb_relaxed(portaddr(port, reg))) |
| 121 | #define rd_regl(port, reg) (readl_relaxed(portaddr(port, reg))) |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 122 | |
Matthew Leach | e37697b | 2016-06-22 17:57:02 +0100 | [diff] [blame^] | 123 | #define wr_regb(port, reg, val) writeb_relaxed(val, portaddr(port, reg)) |
| 124 | #define wr_regl(port, reg, val) writel_relaxed(val, portaddr(port, reg)) |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 125 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 126 | #endif |