Greg Kroah-Hartman | e3b3d0f | 2017-11-06 18:11:51 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Joe Perches | e4ac92d | 2014-05-20 14:05:50 -0700 | [diff] [blame] | 2 | #ifndef __SAMSUNG_H |
| 3 | #define __SAMSUNG_H |
| 4 | |
Jovi Zhang | 99edb3d | 2011-03-30 05:30:41 -0400 | [diff] [blame] | 5 | /* |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 6 | * Driver for Samsung SoC onboard UARTs. |
| 7 | * |
Ben Dooks | ccae941 | 2009-11-13 22:54:14 +0000 | [diff] [blame] | 8 | * Ben Dooks, Copyright (c) 2003-2008 Simtec Electronics |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 9 | * http://armlinux.simtec.co.uk/ |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 10 | */ |
| 11 | |
Robert Baldyga | 7bb6b2f | 2014-12-10 12:49:22 +0100 | [diff] [blame] | 12 | #include <linux/dmaengine.h> |
| 13 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 14 | struct s3c24xx_uart_info { |
| 15 | char *name; |
| 16 | unsigned int type; |
| 17 | unsigned int fifosize; |
| 18 | unsigned long rx_fifomask; |
| 19 | unsigned long rx_fifoshift; |
| 20 | unsigned long rx_fifofull; |
| 21 | unsigned long tx_fifomask; |
| 22 | unsigned long tx_fifoshift; |
| 23 | unsigned long tx_fifofull; |
Thomas Abraham | 5f5a7a5 | 2011-10-24 11:47:46 +0200 | [diff] [blame] | 24 | unsigned int def_clk_sel; |
| 25 | unsigned long num_clks; |
| 26 | unsigned long clksel_mask; |
| 27 | unsigned long clksel_shift; |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 28 | |
Ben Dooks | 090f848 | 2008-12-12 00:24:21 +0000 | [diff] [blame] | 29 | /* uart port features */ |
| 30 | |
| 31 | unsigned int has_divslot:1; |
| 32 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 33 | /* uart controls */ |
| 34 | int (*reset_port)(struct uart_port *, struct s3c2410_uartcfg *); |
| 35 | }; |
| 36 | |
Thomas Abraham | da12150 | 2011-11-02 19:23:25 +0900 | [diff] [blame] | 37 | struct s3c24xx_serial_drv_data { |
| 38 | struct s3c24xx_uart_info *info; |
| 39 | struct s3c2410_uartcfg *def_cfg; |
| 40 | unsigned int fifosize[CONFIG_SERIAL_SAMSUNG_UARTS]; |
| 41 | }; |
| 42 | |
Robert Baldyga | 7bb6b2f | 2014-12-10 12:49:22 +0100 | [diff] [blame] | 43 | struct s3c24xx_uart_dma { |
Robert Baldyga | 7bb6b2f | 2014-12-10 12:49:22 +0100 | [diff] [blame] | 44 | unsigned int rx_chan_id; |
| 45 | unsigned int tx_chan_id; |
| 46 | |
| 47 | struct dma_slave_config rx_conf; |
| 48 | struct dma_slave_config tx_conf; |
| 49 | |
| 50 | struct dma_chan *rx_chan; |
| 51 | struct dma_chan *tx_chan; |
| 52 | |
| 53 | dma_addr_t rx_addr; |
| 54 | dma_addr_t tx_addr; |
| 55 | |
| 56 | dma_cookie_t rx_cookie; |
| 57 | dma_cookie_t tx_cookie; |
| 58 | |
| 59 | char *rx_buf; |
| 60 | |
| 61 | dma_addr_t tx_transfer_addr; |
| 62 | |
| 63 | size_t rx_size; |
| 64 | size_t tx_size; |
| 65 | |
| 66 | struct dma_async_tx_descriptor *tx_desc; |
| 67 | struct dma_async_tx_descriptor *rx_desc; |
| 68 | |
| 69 | int tx_bytes_requested; |
| 70 | int rx_bytes_requested; |
| 71 | }; |
| 72 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 73 | struct s3c24xx_uart_port { |
| 74 | unsigned char rx_claimed; |
| 75 | unsigned char tx_claimed; |
Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 76 | unsigned int pm_level; |
| 77 | unsigned long baudclk_rate; |
Marek Szyprowski | 81ccb2a | 2015-07-31 10:58:27 +0200 | [diff] [blame] | 78 | unsigned int min_dma_size; |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 79 | |
Ben Dooks | b73c289c | 2008-10-21 14:07:04 +0100 | [diff] [blame] | 80 | unsigned int rx_irq; |
| 81 | unsigned int tx_irq; |
| 82 | |
Robert Baldyga | 29bef79 | 2014-12-10 12:49:26 +0100 | [diff] [blame] | 83 | unsigned int tx_in_progress; |
| 84 | unsigned int tx_mode; |
Robert Baldyga | b543c30 | 2014-12-10 12:49:27 +0100 | [diff] [blame] | 85 | unsigned int rx_mode; |
Robert Baldyga | 29bef79 | 2014-12-10 12:49:26 +0100 | [diff] [blame] | 86 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 87 | struct s3c24xx_uart_info *info; |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 88 | struct clk *clk; |
| 89 | struct clk *baudclk; |
| 90 | struct uart_port port; |
Thomas Abraham | da12150 | 2011-11-02 19:23:25 +0900 | [diff] [blame] | 91 | struct s3c24xx_serial_drv_data *drv_data; |
Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 92 | |
Thomas Abraham | 4d84e97 | 2011-10-24 11:47:25 +0200 | [diff] [blame] | 93 | /* reference to platform data */ |
| 94 | struct s3c2410_uartcfg *cfg; |
| 95 | |
Robert Baldyga | 7bb6b2f | 2014-12-10 12:49:22 +0100 | [diff] [blame] | 96 | struct s3c24xx_uart_dma *dma; |
| 97 | |
Krzysztof Kozlowski | ebaa81c | 2016-06-27 13:59:08 +0200 | [diff] [blame] | 98 | #ifdef CONFIG_ARM_S3C24XX_CPUFREQ |
Ben Dooks | 3055547 | 2008-10-21 14:06:36 +0100 | [diff] [blame] | 99 | struct notifier_block freq_transition; |
| 100 | #endif |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 101 | }; |
| 102 | |
| 103 | /* conversion functions */ |
| 104 | |
Jingoo Han | d4aab20 | 2013-09-09 14:10:30 +0900 | [diff] [blame] | 105 | #define s3c24xx_dev_to_port(__dev) dev_get_drvdata(__dev) |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 106 | |
| 107 | /* register access controls */ |
| 108 | |
| 109 | #define portaddr(port, reg) ((port)->membase + (reg)) |
Jingoo Han | 9fdedf5 | 2013-08-08 17:29:48 +0900 | [diff] [blame] | 110 | #define portaddrl(port, reg) \ |
| 111 | ((unsigned long *)(unsigned long)((port)->membase + (reg))) |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 112 | |
Matthew Leach | e37697b | 2016-06-22 17:57:02 +0100 | [diff] [blame] | 113 | #define rd_regb(port, reg) (readb_relaxed(portaddr(port, reg))) |
| 114 | #define rd_regl(port, reg) (readl_relaxed(portaddr(port, reg))) |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 115 | |
Matthew Leach | e37697b | 2016-06-22 17:57:02 +0100 | [diff] [blame] | 116 | #define wr_regb(port, reg, val) writeb_relaxed(val, portaddr(port, reg)) |
| 117 | #define wr_regl(port, reg, val) writel_relaxed(val, portaddr(port, reg)) |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 118 | |
Matthew Leach | bbb5ff9 | 2016-06-22 17:57:03 +0100 | [diff] [blame] | 119 | /* Byte-order aware bit setting/clearing functions. */ |
| 120 | |
| 121 | static inline void s3c24xx_set_bit(struct uart_port *port, int idx, |
| 122 | unsigned int reg) |
| 123 | { |
| 124 | unsigned long flags; |
| 125 | u32 val; |
| 126 | |
| 127 | local_irq_save(flags); |
| 128 | val = rd_regl(port, reg); |
| 129 | val |= (1 << idx); |
| 130 | wr_regl(port, reg, val); |
| 131 | local_irq_restore(flags); |
| 132 | } |
| 133 | |
| 134 | static inline void s3c24xx_clear_bit(struct uart_port *port, int idx, |
| 135 | unsigned int reg) |
| 136 | { |
| 137 | unsigned long flags; |
| 138 | u32 val; |
| 139 | |
| 140 | local_irq_save(flags); |
| 141 | val = rd_regl(port, reg); |
| 142 | val &= ~(1 << idx); |
| 143 | wr_regl(port, reg, val); |
| 144 | local_irq_restore(flags); |
| 145 | } |
| 146 | |
Ben Dooks | b497549 | 2008-07-03 12:32:51 +0100 | [diff] [blame] | 147 | #endif |