162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * MPC8xx Communication Processor Module.
462306a36Sopenharmony_ci * Copyright (c) 1997 Dan Malek (dmalek@jlc.net)
562306a36Sopenharmony_ci *
662306a36Sopenharmony_ci * This file contains structures and information for the communication
762306a36Sopenharmony_ci * processor channels.  Some CPM control and status is available
862306a36Sopenharmony_ci * through the MPC8xx internal memory map.  See immap.h for details.
962306a36Sopenharmony_ci * This file only contains what I need for the moment, not the total
1062306a36Sopenharmony_ci * CPM capabilities.  I (or someone else) will add definitions as they
1162306a36Sopenharmony_ci * are needed.  -- Dan
1262306a36Sopenharmony_ci *
1362306a36Sopenharmony_ci * On the MBX board, EPPC-Bug loads CPM microcode into the first 512
1462306a36Sopenharmony_ci * bytes of the DP RAM and relocates the I2C parameter area to the
1562306a36Sopenharmony_ci * IDMA1 space.  The remaining DP RAM is available for buffer descriptors
1662306a36Sopenharmony_ci * or other use.
1762306a36Sopenharmony_ci */
1862306a36Sopenharmony_ci#ifndef __CPM1__
1962306a36Sopenharmony_ci#define __CPM1__
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci#include <linux/init.h>
2262306a36Sopenharmony_ci#include <asm/8xx_immap.h>
2362306a36Sopenharmony_ci#include <asm/ptrace.h>
2462306a36Sopenharmony_ci#include <asm/cpm.h>
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_ci/* CPM Command register.
2762306a36Sopenharmony_ci*/
2862306a36Sopenharmony_ci#define CPM_CR_RST	((ushort)0x8000)
2962306a36Sopenharmony_ci#define CPM_CR_OPCODE	((ushort)0x0f00)
3062306a36Sopenharmony_ci#define CPM_CR_CHAN	((ushort)0x00f0)
3162306a36Sopenharmony_ci#define CPM_CR_FLG	((ushort)0x0001)
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/* Channel numbers.
3462306a36Sopenharmony_ci*/
3562306a36Sopenharmony_ci#define CPM_CR_CH_SCC1		((ushort)0x0000)
3662306a36Sopenharmony_ci#define CPM_CR_CH_I2C		((ushort)0x0001)	/* I2C and IDMA1 */
3762306a36Sopenharmony_ci#define CPM_CR_CH_SCC2		((ushort)0x0004)
3862306a36Sopenharmony_ci#define CPM_CR_CH_SPI		((ushort)0x0005)	/* SPI / IDMA2 / Timers */
3962306a36Sopenharmony_ci#define CPM_CR_CH_TIMER		CPM_CR_CH_SPI
4062306a36Sopenharmony_ci#define CPM_CR_CH_SCC3		((ushort)0x0008)
4162306a36Sopenharmony_ci#define CPM_CR_CH_SMC1		((ushort)0x0009)	/* SMC1 / DSP1 */
4262306a36Sopenharmony_ci#define CPM_CR_CH_SCC4		((ushort)0x000c)
4362306a36Sopenharmony_ci#define CPM_CR_CH_SMC2		((ushort)0x000d)	/* SMC2 / DSP2 */
4462306a36Sopenharmony_ci
4562306a36Sopenharmony_ci#define mk_cr_cmd(CH, CMD)	((CMD << 8) | (CH << 4))
4662306a36Sopenharmony_ci
4762306a36Sopenharmony_ci/* Export the base address of the communication processor registers
4862306a36Sopenharmony_ci * and dual port ram.
4962306a36Sopenharmony_ci */
5062306a36Sopenharmony_ciextern cpm8xx_t __iomem *cpmp; /* Pointer to comm processor */
5162306a36Sopenharmony_ci
5262306a36Sopenharmony_ci#define cpm_dpalloc cpm_muram_alloc
5362306a36Sopenharmony_ci#define cpm_dpfree cpm_muram_free
5462306a36Sopenharmony_ci#define cpm_dpram_addr cpm_muram_addr
5562306a36Sopenharmony_ci#define cpm_dpram_phys cpm_muram_dma
5662306a36Sopenharmony_ci
5762306a36Sopenharmony_ciextern void cpm_setbrg(uint brg, uint rate);
5862306a36Sopenharmony_ci
5962306a36Sopenharmony_ciextern void __init cpm_load_patch(cpm8xx_t *cp);
6062306a36Sopenharmony_ci
6162306a36Sopenharmony_ciextern void cpm_reset(void);
6262306a36Sopenharmony_ci
6362306a36Sopenharmony_ci/* Parameter RAM offsets.
6462306a36Sopenharmony_ci*/
6562306a36Sopenharmony_ci#define PROFF_SCC1	((uint)0x0000)
6662306a36Sopenharmony_ci#define PROFF_IIC	((uint)0x0080)
6762306a36Sopenharmony_ci#define PROFF_SCC2	((uint)0x0100)
6862306a36Sopenharmony_ci#define PROFF_SPI	((uint)0x0180)
6962306a36Sopenharmony_ci#define PROFF_SCC3	((uint)0x0200)
7062306a36Sopenharmony_ci#define PROFF_SMC1	((uint)0x0280)
7162306a36Sopenharmony_ci#define PROFF_DSP1	((uint)0x02c0)
7262306a36Sopenharmony_ci#define PROFF_SCC4	((uint)0x0300)
7362306a36Sopenharmony_ci#define PROFF_SMC2	((uint)0x0380)
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ci/* Define enough so I can at least use the serial port as a UART.
7662306a36Sopenharmony_ci * The MBX uses SMC1 as the host serial port.
7762306a36Sopenharmony_ci */
7862306a36Sopenharmony_citypedef struct smc_uart {
7962306a36Sopenharmony_ci	ushort	smc_rbase;	/* Rx Buffer descriptor base address */
8062306a36Sopenharmony_ci	ushort	smc_tbase;	/* Tx Buffer descriptor base address */
8162306a36Sopenharmony_ci	u_char	smc_rfcr;	/* Rx function code */
8262306a36Sopenharmony_ci	u_char	smc_tfcr;	/* Tx function code */
8362306a36Sopenharmony_ci	ushort	smc_mrblr;	/* Max receive buffer length */
8462306a36Sopenharmony_ci	uint	smc_rstate;	/* Internal */
8562306a36Sopenharmony_ci	uint	smc_idp;	/* Internal */
8662306a36Sopenharmony_ci	ushort	smc_rbptr;	/* Internal */
8762306a36Sopenharmony_ci	ushort	smc_ibc;	/* Internal */
8862306a36Sopenharmony_ci	uint	smc_rxtmp;	/* Internal */
8962306a36Sopenharmony_ci	uint	smc_tstate;	/* Internal */
9062306a36Sopenharmony_ci	uint	smc_tdp;	/* Internal */
9162306a36Sopenharmony_ci	ushort	smc_tbptr;	/* Internal */
9262306a36Sopenharmony_ci	ushort	smc_tbc;	/* Internal */
9362306a36Sopenharmony_ci	uint	smc_txtmp;	/* Internal */
9462306a36Sopenharmony_ci	ushort	smc_maxidl;	/* Maximum idle characters */
9562306a36Sopenharmony_ci	ushort	smc_tmpidl;	/* Temporary idle counter */
9662306a36Sopenharmony_ci	ushort	smc_brklen;	/* Last received break length */
9762306a36Sopenharmony_ci	ushort	smc_brkec;	/* rcv'd break condition counter */
9862306a36Sopenharmony_ci	ushort	smc_brkcr;	/* xmt break count register */
9962306a36Sopenharmony_ci	ushort	smc_rmask;	/* Temporary bit mask */
10062306a36Sopenharmony_ci	char	res1[8];	/* Reserved */
10162306a36Sopenharmony_ci	ushort	smc_rpbase;	/* Relocation pointer */
10262306a36Sopenharmony_ci} smc_uart_t;
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci/* Function code bits.
10562306a36Sopenharmony_ci*/
10662306a36Sopenharmony_ci#define SMC_EB	((u_char)0x10)	/* Set big endian byte order */
10762306a36Sopenharmony_ci
10862306a36Sopenharmony_ci/* SMC uart mode register.
10962306a36Sopenharmony_ci*/
11062306a36Sopenharmony_ci#define	SMCMR_REN	((ushort)0x0001)
11162306a36Sopenharmony_ci#define SMCMR_TEN	((ushort)0x0002)
11262306a36Sopenharmony_ci#define SMCMR_DM	((ushort)0x000c)
11362306a36Sopenharmony_ci#define SMCMR_SM_GCI	((ushort)0x0000)
11462306a36Sopenharmony_ci#define SMCMR_SM_UART	((ushort)0x0020)
11562306a36Sopenharmony_ci#define SMCMR_SM_TRANS	((ushort)0x0030)
11662306a36Sopenharmony_ci#define SMCMR_SM_MASK	((ushort)0x0030)
11762306a36Sopenharmony_ci#define SMCMR_PM_EVEN	((ushort)0x0100)	/* Even parity, else odd */
11862306a36Sopenharmony_ci#define SMCMR_REVD	SMCMR_PM_EVEN
11962306a36Sopenharmony_ci#define SMCMR_PEN	((ushort)0x0200)	/* Parity enable */
12062306a36Sopenharmony_ci#define SMCMR_BS	SMCMR_PEN
12162306a36Sopenharmony_ci#define SMCMR_SL	((ushort)0x0400)	/* Two stops, else one */
12262306a36Sopenharmony_ci#define SMCR_CLEN_MASK	((ushort)0x7800)	/* Character length */
12362306a36Sopenharmony_ci#define smcr_mk_clen(C)	(((C) << 11) & SMCR_CLEN_MASK)
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci/* SMC2 as Centronics parallel printer.  It is half duplex, in that
12662306a36Sopenharmony_ci * it can only receive or transmit.  The parameter ram values for
12762306a36Sopenharmony_ci * each direction are either unique or properly overlap, so we can
12862306a36Sopenharmony_ci * include them in one structure.
12962306a36Sopenharmony_ci */
13062306a36Sopenharmony_citypedef struct smc_centronics {
13162306a36Sopenharmony_ci	ushort	scent_rbase;
13262306a36Sopenharmony_ci	ushort	scent_tbase;
13362306a36Sopenharmony_ci	u_char	scent_cfcr;
13462306a36Sopenharmony_ci	u_char	scent_smask;
13562306a36Sopenharmony_ci	ushort	scent_mrblr;
13662306a36Sopenharmony_ci	uint	scent_rstate;
13762306a36Sopenharmony_ci	uint	scent_r_ptr;
13862306a36Sopenharmony_ci	ushort	scent_rbptr;
13962306a36Sopenharmony_ci	ushort	scent_r_cnt;
14062306a36Sopenharmony_ci	uint	scent_rtemp;
14162306a36Sopenharmony_ci	uint	scent_tstate;
14262306a36Sopenharmony_ci	uint	scent_t_ptr;
14362306a36Sopenharmony_ci	ushort	scent_tbptr;
14462306a36Sopenharmony_ci	ushort	scent_t_cnt;
14562306a36Sopenharmony_ci	uint	scent_ttemp;
14662306a36Sopenharmony_ci	ushort	scent_max_sl;
14762306a36Sopenharmony_ci	ushort	scent_sl_cnt;
14862306a36Sopenharmony_ci	ushort	scent_character1;
14962306a36Sopenharmony_ci	ushort	scent_character2;
15062306a36Sopenharmony_ci	ushort	scent_character3;
15162306a36Sopenharmony_ci	ushort	scent_character4;
15262306a36Sopenharmony_ci	ushort	scent_character5;
15362306a36Sopenharmony_ci	ushort	scent_character6;
15462306a36Sopenharmony_ci	ushort	scent_character7;
15562306a36Sopenharmony_ci	ushort	scent_character8;
15662306a36Sopenharmony_ci	ushort	scent_rccm;
15762306a36Sopenharmony_ci	ushort	scent_rccr;
15862306a36Sopenharmony_ci} smc_cent_t;
15962306a36Sopenharmony_ci
16062306a36Sopenharmony_ci/* Centronics Status Mask Register.
16162306a36Sopenharmony_ci*/
16262306a36Sopenharmony_ci#define SMC_CENT_F	((u_char)0x08)
16362306a36Sopenharmony_ci#define SMC_CENT_PE	((u_char)0x04)
16462306a36Sopenharmony_ci#define SMC_CENT_S	((u_char)0x02)
16562306a36Sopenharmony_ci
16662306a36Sopenharmony_ci/* SMC Event and Mask register.
16762306a36Sopenharmony_ci*/
16862306a36Sopenharmony_ci#define	SMCM_BRKE	((unsigned char)0x40)	/* When in UART Mode */
16962306a36Sopenharmony_ci#define	SMCM_BRK	((unsigned char)0x10)	/* When in UART Mode */
17062306a36Sopenharmony_ci#define	SMCM_TXE	((unsigned char)0x10)	/* When in Transparent Mode */
17162306a36Sopenharmony_ci#define	SMCM_BSY	((unsigned char)0x04)
17262306a36Sopenharmony_ci#define	SMCM_TX		((unsigned char)0x02)
17362306a36Sopenharmony_ci#define	SMCM_RX		((unsigned char)0x01)
17462306a36Sopenharmony_ci
17562306a36Sopenharmony_ci/* Baud rate generators.
17662306a36Sopenharmony_ci*/
17762306a36Sopenharmony_ci#define CPM_BRG_RST		((uint)0x00020000)
17862306a36Sopenharmony_ci#define CPM_BRG_EN		((uint)0x00010000)
17962306a36Sopenharmony_ci#define CPM_BRG_EXTC_INT	((uint)0x00000000)
18062306a36Sopenharmony_ci#define CPM_BRG_EXTC_CLK2	((uint)0x00004000)
18162306a36Sopenharmony_ci#define CPM_BRG_EXTC_CLK6	((uint)0x00008000)
18262306a36Sopenharmony_ci#define CPM_BRG_ATB		((uint)0x00002000)
18362306a36Sopenharmony_ci#define CPM_BRG_CD_MASK		((uint)0x00001ffe)
18462306a36Sopenharmony_ci#define CPM_BRG_DIV16		((uint)0x00000001)
18562306a36Sopenharmony_ci
18662306a36Sopenharmony_ci/* SI Clock Route Register
18762306a36Sopenharmony_ci*/
18862306a36Sopenharmony_ci#define SICR_RCLK_SCC1_BRG1	((uint)0x00000000)
18962306a36Sopenharmony_ci#define SICR_TCLK_SCC1_BRG1	((uint)0x00000000)
19062306a36Sopenharmony_ci#define SICR_RCLK_SCC2_BRG2	((uint)0x00000800)
19162306a36Sopenharmony_ci#define SICR_TCLK_SCC2_BRG2	((uint)0x00000100)
19262306a36Sopenharmony_ci#define SICR_RCLK_SCC3_BRG3	((uint)0x00100000)
19362306a36Sopenharmony_ci#define SICR_TCLK_SCC3_BRG3	((uint)0x00020000)
19462306a36Sopenharmony_ci#define SICR_RCLK_SCC4_BRG4	((uint)0x18000000)
19562306a36Sopenharmony_ci#define SICR_TCLK_SCC4_BRG4	((uint)0x03000000)
19662306a36Sopenharmony_ci
19762306a36Sopenharmony_ci/* SCCs.
19862306a36Sopenharmony_ci*/
19962306a36Sopenharmony_ci#define SCC_GSMRH_IRP		((uint)0x00040000)
20062306a36Sopenharmony_ci#define SCC_GSMRH_GDE		((uint)0x00010000)
20162306a36Sopenharmony_ci#define SCC_GSMRH_TCRC_CCITT	((uint)0x00008000)
20262306a36Sopenharmony_ci#define SCC_GSMRH_TCRC_BISYNC	((uint)0x00004000)
20362306a36Sopenharmony_ci#define SCC_GSMRH_TCRC_HDLC	((uint)0x00000000)
20462306a36Sopenharmony_ci#define SCC_GSMRH_REVD		((uint)0x00002000)
20562306a36Sopenharmony_ci#define SCC_GSMRH_TRX		((uint)0x00001000)
20662306a36Sopenharmony_ci#define SCC_GSMRH_TTX		((uint)0x00000800)
20762306a36Sopenharmony_ci#define SCC_GSMRH_CDP		((uint)0x00000400)
20862306a36Sopenharmony_ci#define SCC_GSMRH_CTSP		((uint)0x00000200)
20962306a36Sopenharmony_ci#define SCC_GSMRH_CDS		((uint)0x00000100)
21062306a36Sopenharmony_ci#define SCC_GSMRH_CTSS		((uint)0x00000080)
21162306a36Sopenharmony_ci#define SCC_GSMRH_TFL		((uint)0x00000040)
21262306a36Sopenharmony_ci#define SCC_GSMRH_RFW		((uint)0x00000020)
21362306a36Sopenharmony_ci#define SCC_GSMRH_TXSY		((uint)0x00000010)
21462306a36Sopenharmony_ci#define SCC_GSMRH_SYNL16	((uint)0x0000000c)
21562306a36Sopenharmony_ci#define SCC_GSMRH_SYNL8		((uint)0x00000008)
21662306a36Sopenharmony_ci#define SCC_GSMRH_SYNL4		((uint)0x00000004)
21762306a36Sopenharmony_ci#define SCC_GSMRH_RTSM		((uint)0x00000002)
21862306a36Sopenharmony_ci#define SCC_GSMRH_RSYN		((uint)0x00000001)
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_ci#define SCC_GSMRL_SIR		((uint)0x80000000)	/* SCC2 only */
22162306a36Sopenharmony_ci#define SCC_GSMRL_EDGE_NONE	((uint)0x60000000)
22262306a36Sopenharmony_ci#define SCC_GSMRL_EDGE_NEG	((uint)0x40000000)
22362306a36Sopenharmony_ci#define SCC_GSMRL_EDGE_POS	((uint)0x20000000)
22462306a36Sopenharmony_ci#define SCC_GSMRL_EDGE_BOTH	((uint)0x00000000)
22562306a36Sopenharmony_ci#define SCC_GSMRL_TCI		((uint)0x10000000)
22662306a36Sopenharmony_ci#define SCC_GSMRL_TSNC_3	((uint)0x0c000000)
22762306a36Sopenharmony_ci#define SCC_GSMRL_TSNC_4	((uint)0x08000000)
22862306a36Sopenharmony_ci#define SCC_GSMRL_TSNC_14	((uint)0x04000000)
22962306a36Sopenharmony_ci#define SCC_GSMRL_TSNC_INF	((uint)0x00000000)
23062306a36Sopenharmony_ci#define SCC_GSMRL_RINV		((uint)0x02000000)
23162306a36Sopenharmony_ci#define SCC_GSMRL_TINV		((uint)0x01000000)
23262306a36Sopenharmony_ci#define SCC_GSMRL_TPL_128	((uint)0x00c00000)
23362306a36Sopenharmony_ci#define SCC_GSMRL_TPL_64	((uint)0x00a00000)
23462306a36Sopenharmony_ci#define SCC_GSMRL_TPL_48	((uint)0x00800000)
23562306a36Sopenharmony_ci#define SCC_GSMRL_TPL_32	((uint)0x00600000)
23662306a36Sopenharmony_ci#define SCC_GSMRL_TPL_16	((uint)0x00400000)
23762306a36Sopenharmony_ci#define SCC_GSMRL_TPL_8		((uint)0x00200000)
23862306a36Sopenharmony_ci#define SCC_GSMRL_TPL_NONE	((uint)0x00000000)
23962306a36Sopenharmony_ci#define SCC_GSMRL_TPP_ALL1	((uint)0x00180000)
24062306a36Sopenharmony_ci#define SCC_GSMRL_TPP_01	((uint)0x00100000)
24162306a36Sopenharmony_ci#define SCC_GSMRL_TPP_10	((uint)0x00080000)
24262306a36Sopenharmony_ci#define SCC_GSMRL_TPP_ZEROS	((uint)0x00000000)
24362306a36Sopenharmony_ci#define SCC_GSMRL_TEND		((uint)0x00040000)
24462306a36Sopenharmony_ci#define SCC_GSMRL_TDCR_32	((uint)0x00030000)
24562306a36Sopenharmony_ci#define SCC_GSMRL_TDCR_16	((uint)0x00020000)
24662306a36Sopenharmony_ci#define SCC_GSMRL_TDCR_8	((uint)0x00010000)
24762306a36Sopenharmony_ci#define SCC_GSMRL_TDCR_1	((uint)0x00000000)
24862306a36Sopenharmony_ci#define SCC_GSMRL_RDCR_32	((uint)0x0000c000)
24962306a36Sopenharmony_ci#define SCC_GSMRL_RDCR_16	((uint)0x00008000)
25062306a36Sopenharmony_ci#define SCC_GSMRL_RDCR_8	((uint)0x00004000)
25162306a36Sopenharmony_ci#define SCC_GSMRL_RDCR_1	((uint)0x00000000)
25262306a36Sopenharmony_ci#define SCC_GSMRL_RENC_DFMAN	((uint)0x00003000)
25362306a36Sopenharmony_ci#define SCC_GSMRL_RENC_MANCH	((uint)0x00002000)
25462306a36Sopenharmony_ci#define SCC_GSMRL_RENC_FM0	((uint)0x00001000)
25562306a36Sopenharmony_ci#define SCC_GSMRL_RENC_NRZI	((uint)0x00000800)
25662306a36Sopenharmony_ci#define SCC_GSMRL_RENC_NRZ	((uint)0x00000000)
25762306a36Sopenharmony_ci#define SCC_GSMRL_TENC_DFMAN	((uint)0x00000600)
25862306a36Sopenharmony_ci#define SCC_GSMRL_TENC_MANCH	((uint)0x00000400)
25962306a36Sopenharmony_ci#define SCC_GSMRL_TENC_FM0	((uint)0x00000200)
26062306a36Sopenharmony_ci#define SCC_GSMRL_TENC_NRZI	((uint)0x00000100)
26162306a36Sopenharmony_ci#define SCC_GSMRL_TENC_NRZ	((uint)0x00000000)
26262306a36Sopenharmony_ci#define SCC_GSMRL_DIAG_LE	((uint)0x000000c0)	/* Loop and echo */
26362306a36Sopenharmony_ci#define SCC_GSMRL_DIAG_ECHO	((uint)0x00000080)
26462306a36Sopenharmony_ci#define SCC_GSMRL_DIAG_LOOP	((uint)0x00000040)
26562306a36Sopenharmony_ci#define SCC_GSMRL_DIAG_NORM	((uint)0x00000000)
26662306a36Sopenharmony_ci#define SCC_GSMRL_ENR		((uint)0x00000020)
26762306a36Sopenharmony_ci#define SCC_GSMRL_ENT		((uint)0x00000010)
26862306a36Sopenharmony_ci#define SCC_GSMRL_MODE_ENET	((uint)0x0000000c)
26962306a36Sopenharmony_ci#define SCC_GSMRL_MODE_QMC	((uint)0x0000000a)
27062306a36Sopenharmony_ci#define SCC_GSMRL_MODE_DDCMP	((uint)0x00000009)
27162306a36Sopenharmony_ci#define SCC_GSMRL_MODE_BISYNC	((uint)0x00000008)
27262306a36Sopenharmony_ci#define SCC_GSMRL_MODE_V14	((uint)0x00000007)
27362306a36Sopenharmony_ci#define SCC_GSMRL_MODE_AHDLC	((uint)0x00000006)
27462306a36Sopenharmony_ci#define SCC_GSMRL_MODE_PROFIBUS	((uint)0x00000005)
27562306a36Sopenharmony_ci#define SCC_GSMRL_MODE_UART	((uint)0x00000004)
27662306a36Sopenharmony_ci#define SCC_GSMRL_MODE_SS7	((uint)0x00000003)
27762306a36Sopenharmony_ci#define SCC_GSMRL_MODE_ATALK	((uint)0x00000002)
27862306a36Sopenharmony_ci#define SCC_GSMRL_MODE_HDLC	((uint)0x00000000)
27962306a36Sopenharmony_ci
28062306a36Sopenharmony_ci#define SCC_TODR_TOD		((ushort)0x8000)
28162306a36Sopenharmony_ci
28262306a36Sopenharmony_ci/* SCC Event and Mask register.
28362306a36Sopenharmony_ci*/
28462306a36Sopenharmony_ci#define	SCCM_TXE	((unsigned char)0x10)
28562306a36Sopenharmony_ci#define	SCCM_BSY	((unsigned char)0x04)
28662306a36Sopenharmony_ci#define	SCCM_TX		((unsigned char)0x02)
28762306a36Sopenharmony_ci#define	SCCM_RX		((unsigned char)0x01)
28862306a36Sopenharmony_ci
28962306a36Sopenharmony_citypedef struct scc_param {
29062306a36Sopenharmony_ci	ushort	scc_rbase;	/* Rx Buffer descriptor base address */
29162306a36Sopenharmony_ci	ushort	scc_tbase;	/* Tx Buffer descriptor base address */
29262306a36Sopenharmony_ci	u_char	scc_rfcr;	/* Rx function code */
29362306a36Sopenharmony_ci	u_char	scc_tfcr;	/* Tx function code */
29462306a36Sopenharmony_ci	ushort	scc_mrblr;	/* Max receive buffer length */
29562306a36Sopenharmony_ci	uint	scc_rstate;	/* Internal */
29662306a36Sopenharmony_ci	uint	scc_idp;	/* Internal */
29762306a36Sopenharmony_ci	ushort	scc_rbptr;	/* Internal */
29862306a36Sopenharmony_ci	ushort	scc_ibc;	/* Internal */
29962306a36Sopenharmony_ci	uint	scc_rxtmp;	/* Internal */
30062306a36Sopenharmony_ci	uint	scc_tstate;	/* Internal */
30162306a36Sopenharmony_ci	uint	scc_tdp;	/* Internal */
30262306a36Sopenharmony_ci	ushort	scc_tbptr;	/* Internal */
30362306a36Sopenharmony_ci	ushort	scc_tbc;	/* Internal */
30462306a36Sopenharmony_ci	uint	scc_txtmp;	/* Internal */
30562306a36Sopenharmony_ci	uint	scc_rcrc;	/* Internal */
30662306a36Sopenharmony_ci	uint	scc_tcrc;	/* Internal */
30762306a36Sopenharmony_ci} sccp_t;
30862306a36Sopenharmony_ci
30962306a36Sopenharmony_ci/* Function code bits.
31062306a36Sopenharmony_ci*/
31162306a36Sopenharmony_ci#define SCC_EB	((u_char)0x10)	/* Set big endian byte order */
31262306a36Sopenharmony_ci
31362306a36Sopenharmony_ci/* CPM Ethernet through SCCx.
31462306a36Sopenharmony_ci */
31562306a36Sopenharmony_citypedef struct scc_enet {
31662306a36Sopenharmony_ci	sccp_t	sen_genscc;
31762306a36Sopenharmony_ci	uint	sen_cpres;	/* Preset CRC */
31862306a36Sopenharmony_ci	uint	sen_cmask;	/* Constant mask for CRC */
31962306a36Sopenharmony_ci	uint	sen_crcec;	/* CRC Error counter */
32062306a36Sopenharmony_ci	uint	sen_alec;	/* alignment error counter */
32162306a36Sopenharmony_ci	uint	sen_disfc;	/* discard frame counter */
32262306a36Sopenharmony_ci	ushort	sen_pads;	/* Tx short frame pad character */
32362306a36Sopenharmony_ci	ushort	sen_retlim;	/* Retry limit threshold */
32462306a36Sopenharmony_ci	ushort	sen_retcnt;	/* Retry limit counter */
32562306a36Sopenharmony_ci	ushort	sen_maxflr;	/* maximum frame length register */
32662306a36Sopenharmony_ci	ushort	sen_minflr;	/* minimum frame length register */
32762306a36Sopenharmony_ci	ushort	sen_maxd1;	/* maximum DMA1 length */
32862306a36Sopenharmony_ci	ushort	sen_maxd2;	/* maximum DMA2 length */
32962306a36Sopenharmony_ci	ushort	sen_maxd;	/* Rx max DMA */
33062306a36Sopenharmony_ci	ushort	sen_dmacnt;	/* Rx DMA counter */
33162306a36Sopenharmony_ci	ushort	sen_maxb;	/* Max BD byte count */
33262306a36Sopenharmony_ci	ushort	sen_gaddr1;	/* Group address filter */
33362306a36Sopenharmony_ci	ushort	sen_gaddr2;
33462306a36Sopenharmony_ci	ushort	sen_gaddr3;
33562306a36Sopenharmony_ci	ushort	sen_gaddr4;
33662306a36Sopenharmony_ci	uint	sen_tbuf0data0;	/* Save area 0 - current frame */
33762306a36Sopenharmony_ci	uint	sen_tbuf0data1;	/* Save area 1 - current frame */
33862306a36Sopenharmony_ci	uint	sen_tbuf0rba;	/* Internal */
33962306a36Sopenharmony_ci	uint	sen_tbuf0crc;	/* Internal */
34062306a36Sopenharmony_ci	ushort	sen_tbuf0bcnt;	/* Internal */
34162306a36Sopenharmony_ci	ushort	sen_paddrh;	/* physical address (MSB) */
34262306a36Sopenharmony_ci	ushort	sen_paddrm;
34362306a36Sopenharmony_ci	ushort	sen_paddrl;	/* physical address (LSB) */
34462306a36Sopenharmony_ci	ushort	sen_pper;	/* persistence */
34562306a36Sopenharmony_ci	ushort	sen_rfbdptr;	/* Rx first BD pointer */
34662306a36Sopenharmony_ci	ushort	sen_tfbdptr;	/* Tx first BD pointer */
34762306a36Sopenharmony_ci	ushort	sen_tlbdptr;	/* Tx last BD pointer */
34862306a36Sopenharmony_ci	uint	sen_tbuf1data0;	/* Save area 0 - current frame */
34962306a36Sopenharmony_ci	uint	sen_tbuf1data1;	/* Save area 1 - current frame */
35062306a36Sopenharmony_ci	uint	sen_tbuf1rba;	/* Internal */
35162306a36Sopenharmony_ci	uint	sen_tbuf1crc;	/* Internal */
35262306a36Sopenharmony_ci	ushort	sen_tbuf1bcnt;	/* Internal */
35362306a36Sopenharmony_ci	ushort	sen_txlen;	/* Tx Frame length counter */
35462306a36Sopenharmony_ci	ushort	sen_iaddr1;	/* Individual address filter */
35562306a36Sopenharmony_ci	ushort	sen_iaddr2;
35662306a36Sopenharmony_ci	ushort	sen_iaddr3;
35762306a36Sopenharmony_ci	ushort	sen_iaddr4;
35862306a36Sopenharmony_ci	ushort	sen_boffcnt;	/* Backoff counter */
35962306a36Sopenharmony_ci
36062306a36Sopenharmony_ci	/* NOTE: Some versions of the manual have the following items
36162306a36Sopenharmony_ci	 * incorrectly documented.  Below is the proper order.
36262306a36Sopenharmony_ci	 */
36362306a36Sopenharmony_ci	ushort	sen_taddrh;	/* temp address (MSB) */
36462306a36Sopenharmony_ci	ushort	sen_taddrm;
36562306a36Sopenharmony_ci	ushort	sen_taddrl;	/* temp address (LSB) */
36662306a36Sopenharmony_ci} scc_enet_t;
36762306a36Sopenharmony_ci
36862306a36Sopenharmony_ci/* SCC Event register as used by Ethernet.
36962306a36Sopenharmony_ci*/
37062306a36Sopenharmony_ci#define SCCE_ENET_GRA	((ushort)0x0080)	/* Graceful stop complete */
37162306a36Sopenharmony_ci#define SCCE_ENET_TXE	((ushort)0x0010)	/* Transmit Error */
37262306a36Sopenharmony_ci#define SCCE_ENET_RXF	((ushort)0x0008)	/* Full frame received */
37362306a36Sopenharmony_ci#define SCCE_ENET_BSY	((ushort)0x0004)	/* All incoming buffers full */
37462306a36Sopenharmony_ci#define SCCE_ENET_TXB	((ushort)0x0002)	/* A buffer was transmitted */
37562306a36Sopenharmony_ci#define SCCE_ENET_RXB	((ushort)0x0001)	/* A buffer was received */
37662306a36Sopenharmony_ci
37762306a36Sopenharmony_ci/* SCC Mode Register (PMSR) as used by Ethernet.
37862306a36Sopenharmony_ci*/
37962306a36Sopenharmony_ci#define SCC_PSMR_HBC	((ushort)0x8000)	/* Enable heartbeat */
38062306a36Sopenharmony_ci#define SCC_PSMR_FC	((ushort)0x4000)	/* Force collision */
38162306a36Sopenharmony_ci#define SCC_PSMR_RSH	((ushort)0x2000)	/* Receive short frames */
38262306a36Sopenharmony_ci#define SCC_PSMR_IAM	((ushort)0x1000)	/* Check individual hash */
38362306a36Sopenharmony_ci#define SCC_PSMR_ENCRC	((ushort)0x0800)	/* Ethernet CRC mode */
38462306a36Sopenharmony_ci#define SCC_PSMR_PRO	((ushort)0x0200)	/* Promiscuous mode */
38562306a36Sopenharmony_ci#define SCC_PSMR_BRO	((ushort)0x0100)	/* Catch broadcast pkts */
38662306a36Sopenharmony_ci#define SCC_PSMR_SBT	((ushort)0x0080)	/* Special backoff timer */
38762306a36Sopenharmony_ci#define SCC_PSMR_LPB	((ushort)0x0040)	/* Set Loopback mode */
38862306a36Sopenharmony_ci#define SCC_PSMR_SIP	((ushort)0x0020)	/* Sample Input Pins */
38962306a36Sopenharmony_ci#define SCC_PSMR_LCW	((ushort)0x0010)	/* Late collision window */
39062306a36Sopenharmony_ci#define SCC_PSMR_NIB22	((ushort)0x000a)	/* Start frame search */
39162306a36Sopenharmony_ci#define SCC_PSMR_FDE	((ushort)0x0001)	/* Full duplex enable */
39262306a36Sopenharmony_ci
39362306a36Sopenharmony_ci/* SCC as UART
39462306a36Sopenharmony_ci*/
39562306a36Sopenharmony_citypedef struct scc_uart {
39662306a36Sopenharmony_ci	sccp_t	scc_genscc;
39762306a36Sopenharmony_ci	char	res1[8];	/* Reserved */
39862306a36Sopenharmony_ci	ushort	scc_maxidl;	/* Maximum idle chars */
39962306a36Sopenharmony_ci	ushort	scc_idlc;	/* temp idle counter */
40062306a36Sopenharmony_ci	ushort	scc_brkcr;	/* Break count register */
40162306a36Sopenharmony_ci	ushort	scc_parec;	/* receive parity error counter */
40262306a36Sopenharmony_ci	ushort	scc_frmec;	/* receive framing error counter */
40362306a36Sopenharmony_ci	ushort	scc_nosec;	/* receive noise counter */
40462306a36Sopenharmony_ci	ushort	scc_brkec;	/* receive break condition counter */
40562306a36Sopenharmony_ci	ushort	scc_brkln;	/* last received break length */
40662306a36Sopenharmony_ci	ushort	scc_uaddr1;	/* UART address character 1 */
40762306a36Sopenharmony_ci	ushort	scc_uaddr2;	/* UART address character 2 */
40862306a36Sopenharmony_ci	ushort	scc_rtemp;	/* Temp storage */
40962306a36Sopenharmony_ci	ushort	scc_toseq;	/* Transmit out of sequence char */
41062306a36Sopenharmony_ci	ushort	scc_char1;	/* control character 1 */
41162306a36Sopenharmony_ci	ushort	scc_char2;	/* control character 2 */
41262306a36Sopenharmony_ci	ushort	scc_char3;	/* control character 3 */
41362306a36Sopenharmony_ci	ushort	scc_char4;	/* control character 4 */
41462306a36Sopenharmony_ci	ushort	scc_char5;	/* control character 5 */
41562306a36Sopenharmony_ci	ushort	scc_char6;	/* control character 6 */
41662306a36Sopenharmony_ci	ushort	scc_char7;	/* control character 7 */
41762306a36Sopenharmony_ci	ushort	scc_char8;	/* control character 8 */
41862306a36Sopenharmony_ci	ushort	scc_rccm;	/* receive control character mask */
41962306a36Sopenharmony_ci	ushort	scc_rccr;	/* receive control character register */
42062306a36Sopenharmony_ci	ushort	scc_rlbc;	/* receive last break character */
42162306a36Sopenharmony_ci} scc_uart_t;
42262306a36Sopenharmony_ci
42362306a36Sopenharmony_ci/* SCC Event and Mask registers when it is used as a UART.
42462306a36Sopenharmony_ci*/
42562306a36Sopenharmony_ci#define UART_SCCM_GLR		((ushort)0x1000)
42662306a36Sopenharmony_ci#define UART_SCCM_GLT		((ushort)0x0800)
42762306a36Sopenharmony_ci#define UART_SCCM_AB		((ushort)0x0200)
42862306a36Sopenharmony_ci#define UART_SCCM_IDL		((ushort)0x0100)
42962306a36Sopenharmony_ci#define UART_SCCM_GRA		((ushort)0x0080)
43062306a36Sopenharmony_ci#define UART_SCCM_BRKE		((ushort)0x0040)
43162306a36Sopenharmony_ci#define UART_SCCM_BRKS		((ushort)0x0020)
43262306a36Sopenharmony_ci#define UART_SCCM_CCR		((ushort)0x0008)
43362306a36Sopenharmony_ci#define UART_SCCM_BSY		((ushort)0x0004)
43462306a36Sopenharmony_ci#define UART_SCCM_TX		((ushort)0x0002)
43562306a36Sopenharmony_ci#define UART_SCCM_RX		((ushort)0x0001)
43662306a36Sopenharmony_ci
43762306a36Sopenharmony_ci/* The SCC PMSR when used as a UART.
43862306a36Sopenharmony_ci*/
43962306a36Sopenharmony_ci#define SCU_PSMR_FLC		((ushort)0x8000)
44062306a36Sopenharmony_ci#define SCU_PSMR_SL		((ushort)0x4000)
44162306a36Sopenharmony_ci#define SCU_PSMR_CL		((ushort)0x3000)
44262306a36Sopenharmony_ci#define SCU_PSMR_UM		((ushort)0x0c00)
44362306a36Sopenharmony_ci#define SCU_PSMR_FRZ		((ushort)0x0200)
44462306a36Sopenharmony_ci#define SCU_PSMR_RZS		((ushort)0x0100)
44562306a36Sopenharmony_ci#define SCU_PSMR_SYN		((ushort)0x0080)
44662306a36Sopenharmony_ci#define SCU_PSMR_DRT		((ushort)0x0040)
44762306a36Sopenharmony_ci#define SCU_PSMR_PEN		((ushort)0x0010)
44862306a36Sopenharmony_ci#define SCU_PSMR_RPM		((ushort)0x000c)
44962306a36Sopenharmony_ci#define SCU_PSMR_REVP		((ushort)0x0008)
45062306a36Sopenharmony_ci#define SCU_PSMR_TPM		((ushort)0x0003)
45162306a36Sopenharmony_ci#define SCU_PSMR_TEVP		((ushort)0x0002)
45262306a36Sopenharmony_ci
45362306a36Sopenharmony_ci/* CPM Transparent mode SCC.
45462306a36Sopenharmony_ci */
45562306a36Sopenharmony_citypedef struct scc_trans {
45662306a36Sopenharmony_ci	sccp_t	st_genscc;
45762306a36Sopenharmony_ci	uint	st_cpres;	/* Preset CRC */
45862306a36Sopenharmony_ci	uint	st_cmask;	/* Constant mask for CRC */
45962306a36Sopenharmony_ci} scc_trans_t;
46062306a36Sopenharmony_ci
46162306a36Sopenharmony_ci/* IIC parameter RAM.
46262306a36Sopenharmony_ci*/
46362306a36Sopenharmony_citypedef struct iic {
46462306a36Sopenharmony_ci	ushort	iic_rbase;	/* Rx Buffer descriptor base address */
46562306a36Sopenharmony_ci	ushort	iic_tbase;	/* Tx Buffer descriptor base address */
46662306a36Sopenharmony_ci	u_char	iic_rfcr;	/* Rx function code */
46762306a36Sopenharmony_ci	u_char	iic_tfcr;	/* Tx function code */
46862306a36Sopenharmony_ci	ushort	iic_mrblr;	/* Max receive buffer length */
46962306a36Sopenharmony_ci	uint	iic_rstate;	/* Internal */
47062306a36Sopenharmony_ci	uint	iic_rdp;	/* Internal */
47162306a36Sopenharmony_ci	ushort	iic_rbptr;	/* Internal */
47262306a36Sopenharmony_ci	ushort	iic_rbc;	/* Internal */
47362306a36Sopenharmony_ci	uint	iic_rxtmp;	/* Internal */
47462306a36Sopenharmony_ci	uint	iic_tstate;	/* Internal */
47562306a36Sopenharmony_ci	uint	iic_tdp;	/* Internal */
47662306a36Sopenharmony_ci	ushort	iic_tbptr;	/* Internal */
47762306a36Sopenharmony_ci	ushort	iic_tbc;	/* Internal */
47862306a36Sopenharmony_ci	uint	iic_txtmp;	/* Internal */
47962306a36Sopenharmony_ci	char	res1[4];	/* Reserved */
48062306a36Sopenharmony_ci	ushort	iic_rpbase;	/* Relocation pointer */
48162306a36Sopenharmony_ci	char	res2[2];	/* Reserved */
48262306a36Sopenharmony_ci} iic_t;
48362306a36Sopenharmony_ci
48462306a36Sopenharmony_ci/*
48562306a36Sopenharmony_ci * RISC Controller Configuration Register definitons
48662306a36Sopenharmony_ci */
48762306a36Sopenharmony_ci#define RCCR_TIME	0x8000			/* RISC Timer Enable */
48862306a36Sopenharmony_ci#define RCCR_TIMEP(t)	(((t) & 0x3F)<<8)	/* RISC Timer Period */
48962306a36Sopenharmony_ci#define RCCR_TIME_MASK	0x00FF			/* not RISC Timer related bits */
49062306a36Sopenharmony_ci
49162306a36Sopenharmony_ci/* RISC Timer Parameter RAM offset */
49262306a36Sopenharmony_ci#define PROFF_RTMR	((uint)0x01B0)
49362306a36Sopenharmony_ci
49462306a36Sopenharmony_citypedef struct risc_timer_pram {
49562306a36Sopenharmony_ci	unsigned short	tm_base;	/* RISC Timer Table Base Address */
49662306a36Sopenharmony_ci	unsigned short	tm_ptr;		/* RISC Timer Table Pointer (internal) */
49762306a36Sopenharmony_ci	unsigned short	r_tmr;		/* RISC Timer Mode Register */
49862306a36Sopenharmony_ci	unsigned short	r_tmv;		/* RISC Timer Valid Register */
49962306a36Sopenharmony_ci	unsigned long	tm_cmd;		/* RISC Timer Command Register */
50062306a36Sopenharmony_ci	unsigned long	tm_cnt;		/* RISC Timer Internal Count */
50162306a36Sopenharmony_ci} rt_pram_t;
50262306a36Sopenharmony_ci
50362306a36Sopenharmony_ci/* Bits in RISC Timer Command Register */
50462306a36Sopenharmony_ci#define TM_CMD_VALID	0x80000000	/* Valid - Enables the timer */
50562306a36Sopenharmony_ci#define TM_CMD_RESTART	0x40000000	/* Restart - for automatic restart */
50662306a36Sopenharmony_ci#define TM_CMD_PWM	0x20000000	/* Run in Pulse Width Modulation Mode */
50762306a36Sopenharmony_ci#define TM_CMD_NUM(n)	(((n)&0xF)<<16)	/* Timer Number */
50862306a36Sopenharmony_ci#define TM_CMD_PERIOD(p) ((p)&0xFFFF)	/* Timer Period */
50962306a36Sopenharmony_ci
51062306a36Sopenharmony_ci/* CPM interrupts.  There are nearly 32 interrupts generated by CPM
51162306a36Sopenharmony_ci * channels or devices.  All of these are presented to the PPC core
51262306a36Sopenharmony_ci * as a single interrupt.  The CPM interrupt handler dispatches its
51362306a36Sopenharmony_ci * own handlers, in a similar fashion to the PPC core handler.  We
51462306a36Sopenharmony_ci * use the table as defined in the manuals (i.e. no special high
51562306a36Sopenharmony_ci * priority and SCC1 == SCCa, etc...).
51662306a36Sopenharmony_ci */
51762306a36Sopenharmony_ci#define CPMVEC_NR		32
51862306a36Sopenharmony_ci#define	CPMVEC_PIO_PC15		((ushort)0x1f)
51962306a36Sopenharmony_ci#define	CPMVEC_SCC1		((ushort)0x1e)
52062306a36Sopenharmony_ci#define	CPMVEC_SCC2		((ushort)0x1d)
52162306a36Sopenharmony_ci#define	CPMVEC_SCC3		((ushort)0x1c)
52262306a36Sopenharmony_ci#define	CPMVEC_SCC4		((ushort)0x1b)
52362306a36Sopenharmony_ci#define	CPMVEC_PIO_PC14		((ushort)0x1a)
52462306a36Sopenharmony_ci#define	CPMVEC_TIMER1		((ushort)0x19)
52562306a36Sopenharmony_ci#define	CPMVEC_PIO_PC13		((ushort)0x18)
52662306a36Sopenharmony_ci#define	CPMVEC_PIO_PC12		((ushort)0x17)
52762306a36Sopenharmony_ci#define	CPMVEC_SDMA_CB_ERR	((ushort)0x16)
52862306a36Sopenharmony_ci#define CPMVEC_IDMA1		((ushort)0x15)
52962306a36Sopenharmony_ci#define CPMVEC_IDMA2		((ushort)0x14)
53062306a36Sopenharmony_ci#define CPMVEC_TIMER2		((ushort)0x12)
53162306a36Sopenharmony_ci#define CPMVEC_RISCTIMER	((ushort)0x11)
53262306a36Sopenharmony_ci#define CPMVEC_I2C		((ushort)0x10)
53362306a36Sopenharmony_ci#define	CPMVEC_PIO_PC11		((ushort)0x0f)
53462306a36Sopenharmony_ci#define	CPMVEC_PIO_PC10		((ushort)0x0e)
53562306a36Sopenharmony_ci#define CPMVEC_TIMER3		((ushort)0x0c)
53662306a36Sopenharmony_ci#define	CPMVEC_PIO_PC9		((ushort)0x0b)
53762306a36Sopenharmony_ci#define	CPMVEC_PIO_PC8		((ushort)0x0a)
53862306a36Sopenharmony_ci#define	CPMVEC_PIO_PC7		((ushort)0x09)
53962306a36Sopenharmony_ci#define CPMVEC_TIMER4		((ushort)0x07)
54062306a36Sopenharmony_ci#define	CPMVEC_PIO_PC6		((ushort)0x06)
54162306a36Sopenharmony_ci#define	CPMVEC_SPI		((ushort)0x05)
54262306a36Sopenharmony_ci#define	CPMVEC_SMC1		((ushort)0x04)
54362306a36Sopenharmony_ci#define	CPMVEC_SMC2		((ushort)0x03)
54462306a36Sopenharmony_ci#define	CPMVEC_PIO_PC5		((ushort)0x02)
54562306a36Sopenharmony_ci#define	CPMVEC_PIO_PC4		((ushort)0x01)
54662306a36Sopenharmony_ci#define	CPMVEC_ERROR		((ushort)0x00)
54762306a36Sopenharmony_ci
54862306a36Sopenharmony_ci/* CPM interrupt configuration vector.
54962306a36Sopenharmony_ci*/
55062306a36Sopenharmony_ci#define	CICR_SCD_SCC4		((uint)0x00c00000)	/* SCC4 @ SCCd */
55162306a36Sopenharmony_ci#define	CICR_SCC_SCC3		((uint)0x00200000)	/* SCC3 @ SCCc */
55262306a36Sopenharmony_ci#define	CICR_SCB_SCC2		((uint)0x00040000)	/* SCC2 @ SCCb */
55362306a36Sopenharmony_ci#define	CICR_SCA_SCC1		((uint)0x00000000)	/* SCC1 @ SCCa */
55462306a36Sopenharmony_ci#define CICR_IRL_MASK		((uint)0x0000e000)	/* Core interrupt */
55562306a36Sopenharmony_ci#define CICR_HP_MASK		((uint)0x00001f00)	/* Hi-pri int. */
55662306a36Sopenharmony_ci#define CICR_IEN		((uint)0x00000080)	/* Int. enable */
55762306a36Sopenharmony_ci#define CICR_SPS		((uint)0x00000001)	/* SCC Spread */
55862306a36Sopenharmony_ci
55962306a36Sopenharmony_ci#define CPM_PIN_INPUT     0
56062306a36Sopenharmony_ci#define CPM_PIN_OUTPUT    1
56162306a36Sopenharmony_ci#define CPM_PIN_PRIMARY   0
56262306a36Sopenharmony_ci#define CPM_PIN_SECONDARY 2
56362306a36Sopenharmony_ci#define CPM_PIN_GPIO      4
56462306a36Sopenharmony_ci#define CPM_PIN_OPENDRAIN 8
56562306a36Sopenharmony_ci#define CPM_PIN_FALLEDGE  16
56662306a36Sopenharmony_ci#define CPM_PIN_ANYEDGE   0
56762306a36Sopenharmony_ci
56862306a36Sopenharmony_cienum cpm_port {
56962306a36Sopenharmony_ci	CPM_PORTA,
57062306a36Sopenharmony_ci	CPM_PORTB,
57162306a36Sopenharmony_ci	CPM_PORTC,
57262306a36Sopenharmony_ci	CPM_PORTD,
57362306a36Sopenharmony_ci	CPM_PORTE,
57462306a36Sopenharmony_ci};
57562306a36Sopenharmony_ci
57662306a36Sopenharmony_civoid cpm1_set_pin(enum cpm_port port, int pin, int flags);
57762306a36Sopenharmony_ci
57862306a36Sopenharmony_cienum cpm_clk_dir {
57962306a36Sopenharmony_ci	CPM_CLK_RX,
58062306a36Sopenharmony_ci	CPM_CLK_TX,
58162306a36Sopenharmony_ci	CPM_CLK_RTX
58262306a36Sopenharmony_ci};
58362306a36Sopenharmony_ci
58462306a36Sopenharmony_cienum cpm_clk_target {
58562306a36Sopenharmony_ci	CPM_CLK_SCC1,
58662306a36Sopenharmony_ci	CPM_CLK_SCC2,
58762306a36Sopenharmony_ci	CPM_CLK_SCC3,
58862306a36Sopenharmony_ci	CPM_CLK_SCC4,
58962306a36Sopenharmony_ci	CPM_CLK_SMC1,
59062306a36Sopenharmony_ci	CPM_CLK_SMC2,
59162306a36Sopenharmony_ci};
59262306a36Sopenharmony_ci
59362306a36Sopenharmony_cienum cpm_clk {
59462306a36Sopenharmony_ci	CPM_BRG1,	/* Baud Rate Generator  1 */
59562306a36Sopenharmony_ci	CPM_BRG2,	/* Baud Rate Generator  2 */
59662306a36Sopenharmony_ci	CPM_BRG3,	/* Baud Rate Generator  3 */
59762306a36Sopenharmony_ci	CPM_BRG4,	/* Baud Rate Generator  4 */
59862306a36Sopenharmony_ci	CPM_CLK1,	/* Clock  1 */
59962306a36Sopenharmony_ci	CPM_CLK2,	/* Clock  2 */
60062306a36Sopenharmony_ci	CPM_CLK3,	/* Clock  3 */
60162306a36Sopenharmony_ci	CPM_CLK4,	/* Clock  4 */
60262306a36Sopenharmony_ci	CPM_CLK5,	/* Clock  5 */
60362306a36Sopenharmony_ci	CPM_CLK6,	/* Clock  6 */
60462306a36Sopenharmony_ci	CPM_CLK7,	/* Clock  7 */
60562306a36Sopenharmony_ci	CPM_CLK8,	/* Clock  8 */
60662306a36Sopenharmony_ci};
60762306a36Sopenharmony_ci
60862306a36Sopenharmony_ciint cpm1_clk_setup(enum cpm_clk_target target, int clock, int mode);
60962306a36Sopenharmony_ciint cpm1_gpiochip_add16(struct device *dev);
61062306a36Sopenharmony_ciint cpm1_gpiochip_add32(struct device *dev);
61162306a36Sopenharmony_ci
61262306a36Sopenharmony_ci#endif /* __CPM1__ */
613