162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/****************************************************************************/
362306a36Sopenharmony_ci
462306a36Sopenharmony_ci/*
562306a36Sopenharmony_ci *	mcfuart.h -- ColdFire internal UART support defines.
662306a36Sopenharmony_ci *
762306a36Sopenharmony_ci *	(C) Copyright 1999-2003, Greg Ungerer (gerg@snapgear.com)
862306a36Sopenharmony_ci * 	(C) Copyright 2000, Lineo Inc. (www.lineo.com)
962306a36Sopenharmony_ci */
1062306a36Sopenharmony_ci
1162306a36Sopenharmony_ci/****************************************************************************/
1262306a36Sopenharmony_ci#ifndef	mcfuart_h
1362306a36Sopenharmony_ci#define	mcfuart_h
1462306a36Sopenharmony_ci/****************************************************************************/
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ci#include <linux/serial_core.h>
1762306a36Sopenharmony_ci#include <linux/platform_device.h>
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_cistruct mcf_platform_uart {
2062306a36Sopenharmony_ci	unsigned long	mapbase;	/* Physical address base */
2162306a36Sopenharmony_ci	void __iomem	*membase;	/* Virtual address if mapped */
2262306a36Sopenharmony_ci	unsigned int	irq;		/* Interrupt vector */
2362306a36Sopenharmony_ci	unsigned int	uartclk;	/* UART clock rate */
2462306a36Sopenharmony_ci};
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci/*
2762306a36Sopenharmony_ci *	Define the ColdFire UART register set addresses.
2862306a36Sopenharmony_ci */
2962306a36Sopenharmony_ci#define	MCFUART_UMR		0x00		/* Mode register (r/w) */
3062306a36Sopenharmony_ci#define	MCFUART_USR		0x04		/* Status register (r) */
3162306a36Sopenharmony_ci#define	MCFUART_UCSR		0x04		/* Clock Select (w) */
3262306a36Sopenharmony_ci#define	MCFUART_UCR		0x08		/* Command register (w) */
3362306a36Sopenharmony_ci#define	MCFUART_URB		0x0c		/* Receiver Buffer (r) */
3462306a36Sopenharmony_ci#define	MCFUART_UTB		0x0c		/* Transmit Buffer (w) */
3562306a36Sopenharmony_ci#define	MCFUART_UIPCR		0x10		/* Input Port Change (r) */
3662306a36Sopenharmony_ci#define	MCFUART_UACR		0x10		/* Auxiliary Control (w) */
3762306a36Sopenharmony_ci#define	MCFUART_UISR		0x14		/* Interrupt Status (r) */
3862306a36Sopenharmony_ci#define	MCFUART_UIMR		0x14		/* Interrupt Mask (w) */
3962306a36Sopenharmony_ci#define	MCFUART_UBG1		0x18		/* Baud Rate MSB (r/w) */
4062306a36Sopenharmony_ci#define	MCFUART_UBG2		0x1c		/* Baud Rate LSB (r/w) */
4162306a36Sopenharmony_ci#ifdef	CONFIG_M5272
4262306a36Sopenharmony_ci#define	MCFUART_UTF		0x28		/* Transmitter FIFO (r/w) */
4362306a36Sopenharmony_ci#define	MCFUART_URF		0x2c		/* Receiver FIFO (r/w) */
4462306a36Sopenharmony_ci#define	MCFUART_UFPD		0x30		/* Frac Prec. Divider (r/w) */
4562306a36Sopenharmony_ci#endif
4662306a36Sopenharmony_ci#if defined(CONFIG_M5206) || defined(CONFIG_M5206e) || \
4762306a36Sopenharmony_ci	defined(CONFIG_M5249) || defined(CONFIG_M525x) || \
4862306a36Sopenharmony_ci	defined(CONFIG_M5307) || defined(CONFIG_M5407)
4962306a36Sopenharmony_ci#define	MCFUART_UIVR		0x30		/* Interrupt Vector (r/w) */
5062306a36Sopenharmony_ci#endif
5162306a36Sopenharmony_ci#define	MCFUART_UIPR		0x34		/* Input Port (r) */
5262306a36Sopenharmony_ci#define	MCFUART_UOP1		0x38		/* Output Port Bit Set (w) */
5362306a36Sopenharmony_ci#define	MCFUART_UOP0		0x3c		/* Output Port Bit Reset (w) */
5462306a36Sopenharmony_ci
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ci/*
5762306a36Sopenharmony_ci *	Define bit flags in Mode Register 1 (MR1).
5862306a36Sopenharmony_ci */
5962306a36Sopenharmony_ci#define	MCFUART_MR1_RXRTS	0x80		/* Auto RTS flow control */
6062306a36Sopenharmony_ci#define	MCFUART_MR1_RXIRQFULL	0x40		/* RX IRQ type FULL */
6162306a36Sopenharmony_ci#define	MCFUART_MR1_RXIRQRDY	0x00		/* RX IRQ type RDY */
6262306a36Sopenharmony_ci#define	MCFUART_MR1_RXERRBLOCK	0x20		/* RX block error mode */
6362306a36Sopenharmony_ci#define	MCFUART_MR1_RXERRCHAR	0x00		/* RX char error mode */
6462306a36Sopenharmony_ci
6562306a36Sopenharmony_ci#define	MCFUART_MR1_PARITYNONE	0x10		/* No parity */
6662306a36Sopenharmony_ci#define	MCFUART_MR1_PARITYEVEN	0x00		/* Even parity */
6762306a36Sopenharmony_ci#define	MCFUART_MR1_PARITYODD	0x04		/* Odd parity */
6862306a36Sopenharmony_ci#define	MCFUART_MR1_PARITYSPACE	0x08		/* Space parity */
6962306a36Sopenharmony_ci#define	MCFUART_MR1_PARITYMARK	0x0c		/* Mark parity */
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ci#define	MCFUART_MR1_CS5		0x00		/* 5 bits per char */
7262306a36Sopenharmony_ci#define	MCFUART_MR1_CS6		0x01		/* 6 bits per char */
7362306a36Sopenharmony_ci#define	MCFUART_MR1_CS7		0x02		/* 7 bits per char */
7462306a36Sopenharmony_ci#define	MCFUART_MR1_CS8		0x03		/* 8 bits per char */
7562306a36Sopenharmony_ci
7662306a36Sopenharmony_ci/*
7762306a36Sopenharmony_ci *	Define bit flags in Mode Register 2 (MR2).
7862306a36Sopenharmony_ci */
7962306a36Sopenharmony_ci#define	MCFUART_MR2_LOOPBACK	0x80		/* Loopback mode */
8062306a36Sopenharmony_ci#define	MCFUART_MR2_REMOTELOOP	0xc0		/* Remote loopback mode */
8162306a36Sopenharmony_ci#define	MCFUART_MR2_AUTOECHO	0x40		/* Automatic echo */
8262306a36Sopenharmony_ci#define	MCFUART_MR2_TXRTS	0x20		/* Assert RTS on TX */
8362306a36Sopenharmony_ci#define	MCFUART_MR2_TXCTS	0x10		/* Auto CTS flow control */
8462306a36Sopenharmony_ci
8562306a36Sopenharmony_ci#define	MCFUART_MR2_STOP1	0x07		/* 1 stop bit */
8662306a36Sopenharmony_ci#define	MCFUART_MR2_STOP15	0x08		/* 1.5 stop bits */
8762306a36Sopenharmony_ci#define	MCFUART_MR2_STOP2	0x0f		/* 2 stop bits */
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ci/*
9062306a36Sopenharmony_ci *	Define bit flags in Status Register (USR).
9162306a36Sopenharmony_ci */
9262306a36Sopenharmony_ci#define	MCFUART_USR_RXBREAK	0x80		/* Received BREAK */
9362306a36Sopenharmony_ci#define	MCFUART_USR_RXFRAMING	0x40		/* Received framing error */
9462306a36Sopenharmony_ci#define	MCFUART_USR_RXPARITY	0x20		/* Received parity error */
9562306a36Sopenharmony_ci#define	MCFUART_USR_RXOVERRUN	0x10		/* Received overrun error */
9662306a36Sopenharmony_ci#define	MCFUART_USR_TXEMPTY	0x08		/* Transmitter empty */
9762306a36Sopenharmony_ci#define	MCFUART_USR_TXREADY	0x04		/* Transmitter ready */
9862306a36Sopenharmony_ci#define	MCFUART_USR_RXFULL	0x02		/* Receiver full */
9962306a36Sopenharmony_ci#define	MCFUART_USR_RXREADY	0x01		/* Receiver ready */
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci#define	MCFUART_USR_RXERR	(MCFUART_USR_RXBREAK | MCFUART_USR_RXFRAMING | \
10262306a36Sopenharmony_ci				MCFUART_USR_RXPARITY | MCFUART_USR_RXOVERRUN)
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci/*
10562306a36Sopenharmony_ci *	Define bit flags in Clock Select Register (UCSR).
10662306a36Sopenharmony_ci */
10762306a36Sopenharmony_ci#define	MCFUART_UCSR_RXCLKTIMER	0xd0		/* RX clock is timer */
10862306a36Sopenharmony_ci#define	MCFUART_UCSR_RXCLKEXT16	0xe0		/* RX clock is external x16 */
10962306a36Sopenharmony_ci#define	MCFUART_UCSR_RXCLKEXT1	0xf0		/* RX clock is external x1 */
11062306a36Sopenharmony_ci
11162306a36Sopenharmony_ci#define	MCFUART_UCSR_TXCLKTIMER	0x0d		/* TX clock is timer */
11262306a36Sopenharmony_ci#define	MCFUART_UCSR_TXCLKEXT16	0x0e		/* TX clock is external x16 */
11362306a36Sopenharmony_ci#define	MCFUART_UCSR_TXCLKEXT1	0x0f		/* TX clock is external x1 */
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci/*
11662306a36Sopenharmony_ci *	Define bit flags in Command Register (UCR).
11762306a36Sopenharmony_ci */
11862306a36Sopenharmony_ci#define	MCFUART_UCR_CMDNULL		0x00	/* No command */
11962306a36Sopenharmony_ci#define	MCFUART_UCR_CMDRESETMRPTR	0x10	/* Reset MR pointer */
12062306a36Sopenharmony_ci#define	MCFUART_UCR_CMDRESETRX		0x20	/* Reset receiver */
12162306a36Sopenharmony_ci#define	MCFUART_UCR_CMDRESETTX		0x30	/* Reset transmitter */
12262306a36Sopenharmony_ci#define	MCFUART_UCR_CMDRESETERR		0x40	/* Reset error status */
12362306a36Sopenharmony_ci#define	MCFUART_UCR_CMDRESETBREAK	0x50	/* Reset BREAK change */
12462306a36Sopenharmony_ci#define	MCFUART_UCR_CMDBREAKSTART	0x60	/* Start BREAK */
12562306a36Sopenharmony_ci#define	MCFUART_UCR_CMDBREAKSTOP	0x70	/* Stop BREAK */
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ci#define	MCFUART_UCR_TXNULL	0x00		/* No TX command */
12862306a36Sopenharmony_ci#define	MCFUART_UCR_TXENABLE	0x04		/* Enable TX */
12962306a36Sopenharmony_ci#define	MCFUART_UCR_TXDISABLE	0x08		/* Disable TX */
13062306a36Sopenharmony_ci#define	MCFUART_UCR_RXNULL	0x00		/* No RX command */
13162306a36Sopenharmony_ci#define	MCFUART_UCR_RXENABLE	0x01		/* Enable RX */
13262306a36Sopenharmony_ci#define	MCFUART_UCR_RXDISABLE	0x02		/* Disable RX */
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci/*
13562306a36Sopenharmony_ci *	Define bit flags in Input Port Change Register (UIPCR).
13662306a36Sopenharmony_ci */
13762306a36Sopenharmony_ci#define	MCFUART_UIPCR_CTSCOS	0x10		/* CTS change of state */
13862306a36Sopenharmony_ci#define	MCFUART_UIPCR_CTS	0x01		/* CTS value */
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci/*
14162306a36Sopenharmony_ci *	Define bit flags in Input Port Register (UIP).
14262306a36Sopenharmony_ci */
14362306a36Sopenharmony_ci#define	MCFUART_UIPR_CTS	0x01		/* CTS value */
14462306a36Sopenharmony_ci
14562306a36Sopenharmony_ci/*
14662306a36Sopenharmony_ci *	Define bit flags in Output Port Registers (UOP).
14762306a36Sopenharmony_ci *	Clear bit by writing to UOP0, set by writing to UOP1.
14862306a36Sopenharmony_ci */
14962306a36Sopenharmony_ci#define	MCFUART_UOP_RTS		0x01		/* RTS set or clear */
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci/*
15262306a36Sopenharmony_ci *	Define bit flags in the Auxiliary Control Register (UACR).
15362306a36Sopenharmony_ci */
15462306a36Sopenharmony_ci#define	MCFUART_UACR_IEC	0x01		/* Input enable control */
15562306a36Sopenharmony_ci
15662306a36Sopenharmony_ci/*
15762306a36Sopenharmony_ci *	Define bit flags in Interrupt Status Register (UISR).
15862306a36Sopenharmony_ci *	These same bits are used for the Interrupt Mask Register (UIMR).
15962306a36Sopenharmony_ci */
16062306a36Sopenharmony_ci#define	MCFUART_UIR_COS		0x80		/* Change of state (CTS) */
16162306a36Sopenharmony_ci#define	MCFUART_UIR_DELTABREAK	0x04		/* Break start or stop */
16262306a36Sopenharmony_ci#define	MCFUART_UIR_RXREADY	0x02		/* Receiver ready */
16362306a36Sopenharmony_ci#define	MCFUART_UIR_TXREADY	0x01		/* Transmitter ready */
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ci#ifdef	CONFIG_M5272
16662306a36Sopenharmony_ci/*
16762306a36Sopenharmony_ci *	Define bit flags in the Transmitter FIFO Register (UTF).
16862306a36Sopenharmony_ci */
16962306a36Sopenharmony_ci#define	MCFUART_UTF_TXB		0x1f		/* Transmitter data level */
17062306a36Sopenharmony_ci#define	MCFUART_UTF_FULL	0x20		/* Transmitter fifo full */
17162306a36Sopenharmony_ci#define	MCFUART_UTF_TXS		0xc0		/* Transmitter status */
17262306a36Sopenharmony_ci
17362306a36Sopenharmony_ci/*
17462306a36Sopenharmony_ci *	Define bit flags in the Receiver FIFO Register (URF).
17562306a36Sopenharmony_ci */
17662306a36Sopenharmony_ci#define	MCFUART_URF_RXB		0x1f		/* Receiver data level */
17762306a36Sopenharmony_ci#define	MCFUART_URF_FULL	0x20		/* Receiver fifo full */
17862306a36Sopenharmony_ci#define	MCFUART_URF_RXS		0xc0		/* Receiver status */
17962306a36Sopenharmony_ci#endif
18062306a36Sopenharmony_ci
18162306a36Sopenharmony_ci#if defined(CONFIG_M54xx)
18262306a36Sopenharmony_ci#define MCFUART_TXFIFOSIZE	512
18362306a36Sopenharmony_ci#elif defined(CONFIG_M5272)
18462306a36Sopenharmony_ci#define MCFUART_TXFIFOSIZE	25
18562306a36Sopenharmony_ci#else
18662306a36Sopenharmony_ci#define MCFUART_TXFIFOSIZE	1
18762306a36Sopenharmony_ci#endif
18862306a36Sopenharmony_ci/****************************************************************************/
18962306a36Sopenharmony_ci#endif	/* mcfuart_h */
190