1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Driver for CPM (SCC/SMC) serial ports
5 * Copyright (C) 2004 Freescale Semiconductor, Inc.
7 * 2006 (c) MontaVista Software, Inc.
8 * Vitaly Bordug <vbordug@ru.mvista.com>
13 #include <linux/platform_device.h>
17 #if defined(CONFIG_CPM2)
19 #elif defined(CONFIG_CPM1)
23 #define DPRAM_BASE ((u8 __iomem *)cpm_muram_addr(0))
25 #define SERIAL_CPM_MAJOR 204
26 #define SERIAL_CPM_MINOR 46
28 #define IS_SMC(pinfo) (pinfo->flags & FLAG_SMC)
29 #define FLAG_SMC 0x00000002
30 #define FLAG_CONSOLE 0x00000001
35 #define RX_BUF_SIZE 32
37 #define TX_BUF_SIZE 32
46 #define NUM_GPIOS (GPIO_RI+1)
48 struct uart_cpm_port {
49 struct uart_port port;
55 smc_uart_t __iomem *smcup;
57 scc_uart_t __iomem *sccup;
58 cbd_t __iomem *rx_bd_base;
59 cbd_t __iomem *rx_cur;
60 cbd_t __iomem *tx_bd_base;
61 cbd_t __iomem *tx_cur;
62 unsigned char *tx_buf;
63 unsigned char *rx_buf;
71 /* wait on close if needed */
73 /* value to combine with opcode to form cpm command */
75 struct gpio_desc *gpios[NUM_GPIOS];
79 virtual to phys transtalion
81 static inline unsigned long cpu2cpm_addr(void *addr,
82 struct uart_cpm_port *pinfo)
86 u32 mem = (u32)pinfo->mem_addr;
88 if (likely(val >= mem && val < mem + pinfo->mem_size)) {
90 return pinfo->dma_addr + offset;
92 /* something nasty happened */
97 static inline void *cpm2cpu_addr(unsigned long addr,
98 struct uart_cpm_port *pinfo)
102 u32 dma = (u32)pinfo->dma_addr;
104 if (likely(val >= dma && val < dma + pinfo->mem_size)) {
106 return pinfo->mem_addr + offset;
108 /* something nasty happened */
114 #endif /* CPM_UART_H */