18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci/****************************************************************************/
38c2ecf20Sopenharmony_ci
48c2ecf20Sopenharmony_ci/*
58c2ecf20Sopenharmony_ci *	mcfuart.h -- ColdFire internal UART support defines.
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci *	(C) Copyright 1999-2003, Greg Ungerer (gerg@snapgear.com)
88c2ecf20Sopenharmony_ci * 	(C) Copyright 2000, Lineo Inc. (www.lineo.com)
98c2ecf20Sopenharmony_ci */
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ci/****************************************************************************/
128c2ecf20Sopenharmony_ci#ifndef	mcfuart_h
138c2ecf20Sopenharmony_ci#define	mcfuart_h
148c2ecf20Sopenharmony_ci/****************************************************************************/
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_ci#include <linux/serial_core.h>
178c2ecf20Sopenharmony_ci#include <linux/platform_device.h>
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_cistruct mcf_platform_uart {
208c2ecf20Sopenharmony_ci	unsigned long	mapbase;	/* Physical address base */
218c2ecf20Sopenharmony_ci	void __iomem	*membase;	/* Virtual address if mapped */
228c2ecf20Sopenharmony_ci	unsigned int	irq;		/* Interrupt vector */
238c2ecf20Sopenharmony_ci	unsigned int	uartclk;	/* UART clock rate */
248c2ecf20Sopenharmony_ci};
258c2ecf20Sopenharmony_ci
268c2ecf20Sopenharmony_ci/*
278c2ecf20Sopenharmony_ci *	Define the ColdFire UART register set addresses.
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_ci#define	MCFUART_UMR		0x00		/* Mode register (r/w) */
308c2ecf20Sopenharmony_ci#define	MCFUART_USR		0x04		/* Status register (r) */
318c2ecf20Sopenharmony_ci#define	MCFUART_UCSR		0x04		/* Clock Select (w) */
328c2ecf20Sopenharmony_ci#define	MCFUART_UCR		0x08		/* Command register (w) */
338c2ecf20Sopenharmony_ci#define	MCFUART_URB		0x0c		/* Receiver Buffer (r) */
348c2ecf20Sopenharmony_ci#define	MCFUART_UTB		0x0c		/* Transmit Buffer (w) */
358c2ecf20Sopenharmony_ci#define	MCFUART_UIPCR		0x10		/* Input Port Change (r) */
368c2ecf20Sopenharmony_ci#define	MCFUART_UACR		0x10		/* Auxiliary Control (w) */
378c2ecf20Sopenharmony_ci#define	MCFUART_UISR		0x14		/* Interrupt Status (r) */
388c2ecf20Sopenharmony_ci#define	MCFUART_UIMR		0x14		/* Interrupt Mask (w) */
398c2ecf20Sopenharmony_ci#define	MCFUART_UBG1		0x18		/* Baud Rate MSB (r/w) */
408c2ecf20Sopenharmony_ci#define	MCFUART_UBG2		0x1c		/* Baud Rate LSB (r/w) */
418c2ecf20Sopenharmony_ci#ifdef	CONFIG_M5272
428c2ecf20Sopenharmony_ci#define	MCFUART_UTF		0x28		/* Transmitter FIFO (r/w) */
438c2ecf20Sopenharmony_ci#define	MCFUART_URF		0x2c		/* Receiver FIFO (r/w) */
448c2ecf20Sopenharmony_ci#define	MCFUART_UFPD		0x30		/* Frac Prec. Divider (r/w) */
458c2ecf20Sopenharmony_ci#endif
468c2ecf20Sopenharmony_ci#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
478c2ecf20Sopenharmony_ci	defined(CONFIG_M5249) || defined(CONFIG_M525x) || \
488c2ecf20Sopenharmony_ci	defined(CONFIG_M5307) || defined(CONFIG_M5407)
498c2ecf20Sopenharmony_ci#define	MCFUART_UIVR		0x30		/* Interrupt Vector (r/w) */
508c2ecf20Sopenharmony_ci#endif
518c2ecf20Sopenharmony_ci#define	MCFUART_UIPR		0x34		/* Input Port (r) */
528c2ecf20Sopenharmony_ci#define	MCFUART_UOP1		0x38		/* Output Port Bit Set (w) */
538c2ecf20Sopenharmony_ci#define	MCFUART_UOP0		0x3c		/* Output Port Bit Reset (w) */
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ci
568c2ecf20Sopenharmony_ci/*
578c2ecf20Sopenharmony_ci *	Define bit flags in Mode Register 1 (MR1).
588c2ecf20Sopenharmony_ci */
598c2ecf20Sopenharmony_ci#define	MCFUART_MR1_RXRTS	0x80		/* Auto RTS flow control */
608c2ecf20Sopenharmony_ci#define	MCFUART_MR1_RXIRQFULL	0x40		/* RX IRQ type FULL */
618c2ecf20Sopenharmony_ci#define	MCFUART_MR1_RXIRQRDY	0x00		/* RX IRQ type RDY */
628c2ecf20Sopenharmony_ci#define	MCFUART_MR1_RXERRBLOCK	0x20		/* RX block error mode */
638c2ecf20Sopenharmony_ci#define	MCFUART_MR1_RXERRCHAR	0x00		/* RX char error mode */
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ci#define	MCFUART_MR1_PARITYNONE	0x10		/* No parity */
668c2ecf20Sopenharmony_ci#define	MCFUART_MR1_PARITYEVEN	0x00		/* Even parity */
678c2ecf20Sopenharmony_ci#define	MCFUART_MR1_PARITYODD	0x04		/* Odd parity */
688c2ecf20Sopenharmony_ci#define	MCFUART_MR1_PARITYSPACE	0x08		/* Space parity */
698c2ecf20Sopenharmony_ci#define	MCFUART_MR1_PARITYMARK	0x0c		/* Mark parity */
708c2ecf20Sopenharmony_ci
718c2ecf20Sopenharmony_ci#define	MCFUART_MR1_CS5		0x00		/* 5 bits per char */
728c2ecf20Sopenharmony_ci#define	MCFUART_MR1_CS6		0x01		/* 6 bits per char */
738c2ecf20Sopenharmony_ci#define	MCFUART_MR1_CS7		0x02		/* 7 bits per char */
748c2ecf20Sopenharmony_ci#define	MCFUART_MR1_CS8		0x03		/* 8 bits per char */
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci/*
778c2ecf20Sopenharmony_ci *	Define bit flags in Mode Register 2 (MR2).
788c2ecf20Sopenharmony_ci */
798c2ecf20Sopenharmony_ci#define	MCFUART_MR2_LOOPBACK	0x80		/* Loopback mode */
808c2ecf20Sopenharmony_ci#define	MCFUART_MR2_REMOTELOOP	0xc0		/* Remote loopback mode */
818c2ecf20Sopenharmony_ci#define	MCFUART_MR2_AUTOECHO	0x40		/* Automatic echo */
828c2ecf20Sopenharmony_ci#define	MCFUART_MR2_TXRTS	0x20		/* Assert RTS on TX */
838c2ecf20Sopenharmony_ci#define	MCFUART_MR2_TXCTS	0x10		/* Auto CTS flow control */
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define	MCFUART_MR2_STOP1	0x07		/* 1 stop bit */
868c2ecf20Sopenharmony_ci#define	MCFUART_MR2_STOP15	0x08		/* 1.5 stop bits */
878c2ecf20Sopenharmony_ci#define	MCFUART_MR2_STOP2	0x0f		/* 2 stop bits */
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ci/*
908c2ecf20Sopenharmony_ci *	Define bit flags in Status Register (USR).
918c2ecf20Sopenharmony_ci */
928c2ecf20Sopenharmony_ci#define	MCFUART_USR_RXBREAK	0x80		/* Received BREAK */
938c2ecf20Sopenharmony_ci#define	MCFUART_USR_RXFRAMING	0x40		/* Received framing error */
948c2ecf20Sopenharmony_ci#define	MCFUART_USR_RXPARITY	0x20		/* Received parity error */
958c2ecf20Sopenharmony_ci#define	MCFUART_USR_RXOVERRUN	0x10		/* Received overrun error */
968c2ecf20Sopenharmony_ci#define	MCFUART_USR_TXEMPTY	0x08		/* Transmitter empty */
978c2ecf20Sopenharmony_ci#define	MCFUART_USR_TXREADY	0x04		/* Transmitter ready */
988c2ecf20Sopenharmony_ci#define	MCFUART_USR_RXFULL	0x02		/* Receiver full */
998c2ecf20Sopenharmony_ci#define	MCFUART_USR_RXREADY	0x01		/* Receiver ready */
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci#define	MCFUART_USR_RXERR	(MCFUART_USR_RXBREAK | MCFUART_USR_RXFRAMING | \
1028c2ecf20Sopenharmony_ci				MCFUART_USR_RXPARITY | MCFUART_USR_RXOVERRUN)
1038c2ecf20Sopenharmony_ci
1048c2ecf20Sopenharmony_ci/*
1058c2ecf20Sopenharmony_ci *	Define bit flags in Clock Select Register (UCSR).
1068c2ecf20Sopenharmony_ci */
1078c2ecf20Sopenharmony_ci#define	MCFUART_UCSR_RXCLKTIMER	0xd0		/* RX clock is timer */
1088c2ecf20Sopenharmony_ci#define	MCFUART_UCSR_RXCLKEXT16	0xe0		/* RX clock is external x16 */
1098c2ecf20Sopenharmony_ci#define	MCFUART_UCSR_RXCLKEXT1	0xf0		/* RX clock is external x1 */
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_ci#define	MCFUART_UCSR_TXCLKTIMER	0x0d		/* TX clock is timer */
1128c2ecf20Sopenharmony_ci#define	MCFUART_UCSR_TXCLKEXT16	0x0e		/* TX clock is external x16 */
1138c2ecf20Sopenharmony_ci#define	MCFUART_UCSR_TXCLKEXT1	0x0f		/* TX clock is external x1 */
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ci/*
1168c2ecf20Sopenharmony_ci *	Define bit flags in Command Register (UCR).
1178c2ecf20Sopenharmony_ci */
1188c2ecf20Sopenharmony_ci#define	MCFUART_UCR_CMDNULL		0x00	/* No command */
1198c2ecf20Sopenharmony_ci#define	MCFUART_UCR_CMDRESETMRPTR	0x10	/* Reset MR pointer */
1208c2ecf20Sopenharmony_ci#define	MCFUART_UCR_CMDRESETRX		0x20	/* Reset receiver */
1218c2ecf20Sopenharmony_ci#define	MCFUART_UCR_CMDRESETTX		0x30	/* Reset transmitter */
1228c2ecf20Sopenharmony_ci#define	MCFUART_UCR_CMDRESETERR		0x40	/* Reset error status */
1238c2ecf20Sopenharmony_ci#define	MCFUART_UCR_CMDRESETBREAK	0x50	/* Reset BREAK change */
1248c2ecf20Sopenharmony_ci#define	MCFUART_UCR_CMDBREAKSTART	0x60	/* Start BREAK */
1258c2ecf20Sopenharmony_ci#define	MCFUART_UCR_CMDBREAKSTOP	0x70	/* Stop BREAK */
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci#define	MCFUART_UCR_TXNULL	0x00		/* No TX command */
1288c2ecf20Sopenharmony_ci#define	MCFUART_UCR_TXENABLE	0x04		/* Enable TX */
1298c2ecf20Sopenharmony_ci#define	MCFUART_UCR_TXDISABLE	0x08		/* Disable TX */
1308c2ecf20Sopenharmony_ci#define	MCFUART_UCR_RXNULL	0x00		/* No RX command */
1318c2ecf20Sopenharmony_ci#define	MCFUART_UCR_RXENABLE	0x01		/* Enable RX */
1328c2ecf20Sopenharmony_ci#define	MCFUART_UCR_RXDISABLE	0x02		/* Disable RX */
1338c2ecf20Sopenharmony_ci
1348c2ecf20Sopenharmony_ci/*
1358c2ecf20Sopenharmony_ci *	Define bit flags in Input Port Change Register (UIPCR).
1368c2ecf20Sopenharmony_ci */
1378c2ecf20Sopenharmony_ci#define	MCFUART_UIPCR_CTSCOS	0x10		/* CTS change of state */
1388c2ecf20Sopenharmony_ci#define	MCFUART_UIPCR_CTS	0x01		/* CTS value */
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci/*
1418c2ecf20Sopenharmony_ci *	Define bit flags in Input Port Register (UIP).
1428c2ecf20Sopenharmony_ci */
1438c2ecf20Sopenharmony_ci#define	MCFUART_UIPR_CTS	0x01		/* CTS value */
1448c2ecf20Sopenharmony_ci
1458c2ecf20Sopenharmony_ci/*
1468c2ecf20Sopenharmony_ci *	Define bit flags in Output Port Registers (UOP).
1478c2ecf20Sopenharmony_ci *	Clear bit by writing to UOP0, set by writing to UOP1.
1488c2ecf20Sopenharmony_ci */
1498c2ecf20Sopenharmony_ci#define	MCFUART_UOP_RTS		0x01		/* RTS set or clear */
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci/*
1528c2ecf20Sopenharmony_ci *	Define bit flags in the Auxiliary Control Register (UACR).
1538c2ecf20Sopenharmony_ci */
1548c2ecf20Sopenharmony_ci#define	MCFUART_UACR_IEC	0x01		/* Input enable control */
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci/*
1578c2ecf20Sopenharmony_ci *	Define bit flags in Interrupt Status Register (UISR).
1588c2ecf20Sopenharmony_ci *	These same bits are used for the Interrupt Mask Register (UIMR).
1598c2ecf20Sopenharmony_ci */
1608c2ecf20Sopenharmony_ci#define	MCFUART_UIR_COS		0x80		/* Change of state (CTS) */
1618c2ecf20Sopenharmony_ci#define	MCFUART_UIR_DELTABREAK	0x04		/* Break start or stop */
1628c2ecf20Sopenharmony_ci#define	MCFUART_UIR_RXREADY	0x02		/* Receiver ready */
1638c2ecf20Sopenharmony_ci#define	MCFUART_UIR_TXREADY	0x01		/* Transmitter ready */
1648c2ecf20Sopenharmony_ci
1658c2ecf20Sopenharmony_ci#ifdef	CONFIG_M5272
1668c2ecf20Sopenharmony_ci/*
1678c2ecf20Sopenharmony_ci *	Define bit flags in the Transmitter FIFO Register (UTF).
1688c2ecf20Sopenharmony_ci */
1698c2ecf20Sopenharmony_ci#define	MCFUART_UTF_TXB		0x1f		/* Transmitter data level */
1708c2ecf20Sopenharmony_ci#define	MCFUART_UTF_FULL	0x20		/* Transmitter fifo full */
1718c2ecf20Sopenharmony_ci#define	MCFUART_UTF_TXS		0xc0		/* Transmitter status */
1728c2ecf20Sopenharmony_ci
1738c2ecf20Sopenharmony_ci/*
1748c2ecf20Sopenharmony_ci *	Define bit flags in the Receiver FIFO Register (URF).
1758c2ecf20Sopenharmony_ci */
1768c2ecf20Sopenharmony_ci#define	MCFUART_URF_RXB		0x1f		/* Receiver data level */
1778c2ecf20Sopenharmony_ci#define	MCFUART_URF_FULL	0x20		/* Receiver fifo full */
1788c2ecf20Sopenharmony_ci#define	MCFUART_URF_RXS		0xc0		/* Receiver status */
1798c2ecf20Sopenharmony_ci#endif
1808c2ecf20Sopenharmony_ci
1818c2ecf20Sopenharmony_ci#if defined(CONFIG_M54xx)
1828c2ecf20Sopenharmony_ci#define MCFUART_TXFIFOSIZE	512
1838c2ecf20Sopenharmony_ci#elif defined(CONFIG_M5272)
1848c2ecf20Sopenharmony_ci#define MCFUART_TXFIFOSIZE	25
1858c2ecf20Sopenharmony_ci#else
1868c2ecf20Sopenharmony_ci#define MCFUART_TXFIFOSIZE	1
1878c2ecf20Sopenharmony_ci#endif
1888c2ecf20Sopenharmony_ci/****************************************************************************/
1898c2ecf20Sopenharmony_ci#endif	/* mcfuart_h */
190