18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * scc2698.h
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * driver for the IPOCTAL boards
68c2ecf20Sopenharmony_ci *
78c2ecf20Sopenharmony_ci * Copyright (C) 2009-2012 CERN (www.cern.ch)
88c2ecf20Sopenharmony_ci * Author: Nicolas Serafini, EIC2 SA
98c2ecf20Sopenharmony_ci * Author: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
108c2ecf20Sopenharmony_ci */
118c2ecf20Sopenharmony_ci
128c2ecf20Sopenharmony_ci#ifndef SCC2698_H_
138c2ecf20Sopenharmony_ci#define SCC2698_H_
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci/*
168c2ecf20Sopenharmony_ci * union scc2698_channel - Channel access to scc2698 IO
178c2ecf20Sopenharmony_ci *
188c2ecf20Sopenharmony_ci * dn value are only spacer.
198c2ecf20Sopenharmony_ci *
208c2ecf20Sopenharmony_ci */
218c2ecf20Sopenharmony_ciunion scc2698_channel {
228c2ecf20Sopenharmony_ci	struct {
238c2ecf20Sopenharmony_ci		u8 d0, mr;  /* Mode register 1/2*/
248c2ecf20Sopenharmony_ci		u8 d1, sr;  /* Status register */
258c2ecf20Sopenharmony_ci		u8 d2, r1;  /* reserved */
268c2ecf20Sopenharmony_ci		u8 d3, rhr; /* Receive holding register (R) */
278c2ecf20Sopenharmony_ci		u8 junk[8]; /* other crap for block control */
288c2ecf20Sopenharmony_ci	} __packed r; /* Read access */
298c2ecf20Sopenharmony_ci	struct {
308c2ecf20Sopenharmony_ci		u8 d0, mr;  /* Mode register 1/2 */
318c2ecf20Sopenharmony_ci		u8 d1, csr; /* Clock select register */
328c2ecf20Sopenharmony_ci		u8 d2, cr;  /* Command register */
338c2ecf20Sopenharmony_ci		u8 d3, thr; /* Transmit holding register */
348c2ecf20Sopenharmony_ci		u8 junk[8]; /* other crap for block control */
358c2ecf20Sopenharmony_ci	} __packed w; /* Write access */
368c2ecf20Sopenharmony_ci};
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci/*
398c2ecf20Sopenharmony_ci * union scc2698_block - Block access to scc2698 IO
408c2ecf20Sopenharmony_ci *
418c2ecf20Sopenharmony_ci * The scc2698 contain 4 block.
428c2ecf20Sopenharmony_ci * Each block containt two channel a and b.
438c2ecf20Sopenharmony_ci * dn value are only spacer.
448c2ecf20Sopenharmony_ci *
458c2ecf20Sopenharmony_ci */
468c2ecf20Sopenharmony_ciunion scc2698_block {
478c2ecf20Sopenharmony_ci	struct {
488c2ecf20Sopenharmony_ci		u8 d0, mra;  /* Mode register 1/2 (a) */
498c2ecf20Sopenharmony_ci		u8 d1, sra;  /* Status register (a) */
508c2ecf20Sopenharmony_ci		u8 d2, r1;   /* reserved */
518c2ecf20Sopenharmony_ci		u8 d3, rhra; /* Receive holding register (a) */
528c2ecf20Sopenharmony_ci		u8 d4, ipcr; /* Input port change register of block */
538c2ecf20Sopenharmony_ci		u8 d5, isr;  /* Interrupt status register of block */
548c2ecf20Sopenharmony_ci		u8 d6, ctur; /* Counter timer upper register of block */
558c2ecf20Sopenharmony_ci		u8 d7, ctlr; /* Counter timer lower register of block */
568c2ecf20Sopenharmony_ci		u8 d8, mrb;  /* Mode register 1/2 (b) */
578c2ecf20Sopenharmony_ci		u8 d9, srb;  /* Status register (b) */
588c2ecf20Sopenharmony_ci		u8 da, r2;   /* reserved */
598c2ecf20Sopenharmony_ci		u8 db, rhrb; /* Receive holding register (b) */
608c2ecf20Sopenharmony_ci		u8 dc, r3;   /* reserved */
618c2ecf20Sopenharmony_ci		u8 dd, ip;   /* Input port register of block */
628c2ecf20Sopenharmony_ci		u8 de, ctg;  /* Start counter timer of block */
638c2ecf20Sopenharmony_ci		u8 df, cts;  /* Stop counter timer of block */
648c2ecf20Sopenharmony_ci	} __packed r; /* Read access */
658c2ecf20Sopenharmony_ci	struct {
668c2ecf20Sopenharmony_ci		u8 d0, mra;  /* Mode register 1/2 (a) */
678c2ecf20Sopenharmony_ci		u8 d1, csra; /* Clock select register (a) */
688c2ecf20Sopenharmony_ci		u8 d2, cra;  /* Command register (a) */
698c2ecf20Sopenharmony_ci		u8 d3, thra; /* Transmit holding register (a) */
708c2ecf20Sopenharmony_ci		u8 d4, acr;  /* Auxiliary control register of block */
718c2ecf20Sopenharmony_ci		u8 d5, imr;  /* Interrupt mask register of block  */
728c2ecf20Sopenharmony_ci		u8 d6, ctu;  /* Counter timer upper register of block */
738c2ecf20Sopenharmony_ci		u8 d7, ctl;  /* Counter timer lower register of block */
748c2ecf20Sopenharmony_ci		u8 d8, mrb;  /* Mode register 1/2 (b) */
758c2ecf20Sopenharmony_ci		u8 d9, csrb; /* Clock select register (a) */
768c2ecf20Sopenharmony_ci		u8 da, crb;  /* Command register (b) */
778c2ecf20Sopenharmony_ci		u8 db, thrb; /* Transmit holding register (b) */
788c2ecf20Sopenharmony_ci		u8 dc, r1;   /* reserved */
798c2ecf20Sopenharmony_ci		u8 dd, opcr; /* Output port configuration register of block */
808c2ecf20Sopenharmony_ci		u8 de, r2;   /* reserved */
818c2ecf20Sopenharmony_ci		u8 df, r3;   /* reserved */
828c2ecf20Sopenharmony_ci	} __packed w; /* Write access */
838c2ecf20Sopenharmony_ci};
848c2ecf20Sopenharmony_ci
858c2ecf20Sopenharmony_ci#define MR1_CHRL_5_BITS             (0x0 << 0)
868c2ecf20Sopenharmony_ci#define MR1_CHRL_6_BITS             (0x1 << 0)
878c2ecf20Sopenharmony_ci#define MR1_CHRL_7_BITS             (0x2 << 0)
888c2ecf20Sopenharmony_ci#define MR1_CHRL_8_BITS             (0x3 << 0)
898c2ecf20Sopenharmony_ci#define MR1_PARITY_EVEN             (0x1 << 2)
908c2ecf20Sopenharmony_ci#define MR1_PARITY_ODD              (0x0 << 2)
918c2ecf20Sopenharmony_ci#define MR1_PARITY_ON               (0x0 << 3)
928c2ecf20Sopenharmony_ci#define MR1_PARITY_FORCE            (0x1 << 3)
938c2ecf20Sopenharmony_ci#define MR1_PARITY_OFF              (0x2 << 3)
948c2ecf20Sopenharmony_ci#define MR1_PARITY_SPECIAL          (0x3 << 3)
958c2ecf20Sopenharmony_ci#define MR1_ERROR_CHAR              (0x0 << 5)
968c2ecf20Sopenharmony_ci#define MR1_ERROR_BLOCK             (0x1 << 5)
978c2ecf20Sopenharmony_ci#define MR1_RxINT_RxRDY             (0x0 << 6)
988c2ecf20Sopenharmony_ci#define MR1_RxINT_FFULL             (0x1 << 6)
998c2ecf20Sopenharmony_ci#define MR1_RxRTS_CONTROL_ON        (0x1 << 7)
1008c2ecf20Sopenharmony_ci#define MR1_RxRTS_CONTROL_OFF       (0x0 << 7)
1018c2ecf20Sopenharmony_ci
1028c2ecf20Sopenharmony_ci#define MR2_STOP_BITS_LENGTH_1      (0x7 << 0)
1038c2ecf20Sopenharmony_ci#define MR2_STOP_BITS_LENGTH_2      (0xF << 0)
1048c2ecf20Sopenharmony_ci#define MR2_CTS_ENABLE_TX_ON        (0x1 << 4)
1058c2ecf20Sopenharmony_ci#define MR2_CTS_ENABLE_TX_OFF       (0x0 << 4)
1068c2ecf20Sopenharmony_ci#define MR2_TxRTS_CONTROL_ON        (0x1 << 5)
1078c2ecf20Sopenharmony_ci#define MR2_TxRTS_CONTROL_OFF       (0x0 << 5)
1088c2ecf20Sopenharmony_ci#define MR2_CH_MODE_NORMAL          (0x0 << 6)
1098c2ecf20Sopenharmony_ci#define MR2_CH_MODE_ECHO            (0x1 << 6)
1108c2ecf20Sopenharmony_ci#define MR2_CH_MODE_LOCAL           (0x2 << 6)
1118c2ecf20Sopenharmony_ci#define MR2_CH_MODE_REMOTE          (0x3 << 6)
1128c2ecf20Sopenharmony_ci
1138c2ecf20Sopenharmony_ci#define CR_ENABLE_RX                (0x1 << 0)
1148c2ecf20Sopenharmony_ci#define CR_DISABLE_RX               (0x1 << 1)
1158c2ecf20Sopenharmony_ci#define CR_ENABLE_TX                (0x1 << 2)
1168c2ecf20Sopenharmony_ci#define CR_DISABLE_TX               (0x1 << 3)
1178c2ecf20Sopenharmony_ci#define CR_CMD_RESET_MR             (0x1 << 4)
1188c2ecf20Sopenharmony_ci#define CR_CMD_RESET_RX             (0x2 << 4)
1198c2ecf20Sopenharmony_ci#define CR_CMD_RESET_TX             (0x3 << 4)
1208c2ecf20Sopenharmony_ci#define CR_CMD_RESET_ERR_STATUS     (0x4 << 4)
1218c2ecf20Sopenharmony_ci#define CR_CMD_RESET_BREAK_CHANGE   (0x5 << 4)
1228c2ecf20Sopenharmony_ci#define CR_CMD_START_BREAK          (0x6 << 4)
1238c2ecf20Sopenharmony_ci#define CR_CMD_STOP_BREAK           (0x7 << 4)
1248c2ecf20Sopenharmony_ci#define CR_CMD_ASSERT_RTSN          (0x8 << 4)
1258c2ecf20Sopenharmony_ci#define CR_CMD_NEGATE_RTSN          (0x9 << 4)
1268c2ecf20Sopenharmony_ci#define CR_CMD_SET_TIMEOUT_MODE     (0xA << 4)
1278c2ecf20Sopenharmony_ci#define CR_CMD_DISABLE_TIMEOUT_MODE (0xC << 4)
1288c2ecf20Sopenharmony_ci
1298c2ecf20Sopenharmony_ci#define SR_RX_READY                 (0x1 << 0)
1308c2ecf20Sopenharmony_ci#define SR_FIFO_FULL                (0x1 << 1)
1318c2ecf20Sopenharmony_ci#define SR_TX_READY                 (0x1 << 2)
1328c2ecf20Sopenharmony_ci#define SR_TX_EMPTY                 (0x1 << 3)
1338c2ecf20Sopenharmony_ci#define SR_OVERRUN_ERROR            (0x1 << 4)
1348c2ecf20Sopenharmony_ci#define SR_PARITY_ERROR             (0x1 << 5)
1358c2ecf20Sopenharmony_ci#define SR_FRAMING_ERROR            (0x1 << 6)
1368c2ecf20Sopenharmony_ci#define SR_RECEIVED_BREAK           (0x1 << 7)
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ci#define SR_ERROR                    (0xF0)
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci#define ACR_DELTA_IP0_IRQ_EN        (0x1 << 0)
1418c2ecf20Sopenharmony_ci#define ACR_DELTA_IP1_IRQ_EN        (0x1 << 1)
1428c2ecf20Sopenharmony_ci#define ACR_DELTA_IP2_IRQ_EN        (0x1 << 2)
1438c2ecf20Sopenharmony_ci#define ACR_DELTA_IP3_IRQ_EN        (0x1 << 3)
1448c2ecf20Sopenharmony_ci#define ACR_CT_Mask                 (0x7 << 4)
1458c2ecf20Sopenharmony_ci#define ACR_CExt                    (0x0 << 4)
1468c2ecf20Sopenharmony_ci#define ACR_CTxCA                   (0x1 << 4)
1478c2ecf20Sopenharmony_ci#define ACR_CTxCB                   (0x2 << 4)
1488c2ecf20Sopenharmony_ci#define ACR_CClk16                  (0x3 << 4)
1498c2ecf20Sopenharmony_ci#define ACR_TExt                    (0x4 << 4)
1508c2ecf20Sopenharmony_ci#define ACR_TExt16                  (0x5 << 4)
1518c2ecf20Sopenharmony_ci#define ACR_TClk                    (0x6 << 4)
1528c2ecf20Sopenharmony_ci#define ACR_TClk16                  (0x7 << 4)
1538c2ecf20Sopenharmony_ci#define ACR_BRG_SET1                (0x0 << 7)
1548c2ecf20Sopenharmony_ci#define ACR_BRG_SET2                (0x1 << 7)
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ci#define TX_CLK_75                   (0x0 << 0)
1578c2ecf20Sopenharmony_ci#define TX_CLK_110                  (0x1 << 0)
1588c2ecf20Sopenharmony_ci#define TX_CLK_38400                (0x2 << 0)
1598c2ecf20Sopenharmony_ci#define TX_CLK_150                  (0x3 << 0)
1608c2ecf20Sopenharmony_ci#define TX_CLK_300                  (0x4 << 0)
1618c2ecf20Sopenharmony_ci#define TX_CLK_600                  (0x5 << 0)
1628c2ecf20Sopenharmony_ci#define TX_CLK_1200                 (0x6 << 0)
1638c2ecf20Sopenharmony_ci#define TX_CLK_2000                 (0x7 << 0)
1648c2ecf20Sopenharmony_ci#define TX_CLK_2400                 (0x8 << 0)
1658c2ecf20Sopenharmony_ci#define TX_CLK_4800                 (0x9 << 0)
1668c2ecf20Sopenharmony_ci#define TX_CLK_1800                 (0xA << 0)
1678c2ecf20Sopenharmony_ci#define TX_CLK_9600                 (0xB << 0)
1688c2ecf20Sopenharmony_ci#define TX_CLK_19200                (0xC << 0)
1698c2ecf20Sopenharmony_ci#define RX_CLK_75                   (0x0 << 4)
1708c2ecf20Sopenharmony_ci#define RX_CLK_110                  (0x1 << 4)
1718c2ecf20Sopenharmony_ci#define RX_CLK_38400                (0x2 << 4)
1728c2ecf20Sopenharmony_ci#define RX_CLK_150                  (0x3 << 4)
1738c2ecf20Sopenharmony_ci#define RX_CLK_300                  (0x4 << 4)
1748c2ecf20Sopenharmony_ci#define RX_CLK_600                  (0x5 << 4)
1758c2ecf20Sopenharmony_ci#define RX_CLK_1200                 (0x6 << 4)
1768c2ecf20Sopenharmony_ci#define RX_CLK_2000                 (0x7 << 4)
1778c2ecf20Sopenharmony_ci#define RX_CLK_2400                 (0x8 << 4)
1788c2ecf20Sopenharmony_ci#define RX_CLK_4800                 (0x9 << 4)
1798c2ecf20Sopenharmony_ci#define RX_CLK_1800                 (0xA << 4)
1808c2ecf20Sopenharmony_ci#define RX_CLK_9600                 (0xB << 4)
1818c2ecf20Sopenharmony_ci#define RX_CLK_19200                (0xC << 4)
1828c2ecf20Sopenharmony_ci
1838c2ecf20Sopenharmony_ci#define OPCR_MPOa_RTSN              (0x0 << 0)
1848c2ecf20Sopenharmony_ci#define OPCR_MPOa_C_TO              (0x1 << 0)
1858c2ecf20Sopenharmony_ci#define OPCR_MPOa_TxC1X             (0x2 << 0)
1868c2ecf20Sopenharmony_ci#define OPCR_MPOa_TxC16X            (0x3 << 0)
1878c2ecf20Sopenharmony_ci#define OPCR_MPOa_RxC1X             (0x4 << 0)
1888c2ecf20Sopenharmony_ci#define OPCR_MPOa_RxC16X            (0x5 << 0)
1898c2ecf20Sopenharmony_ci#define OPCR_MPOa_TxRDY             (0x6 << 0)
1908c2ecf20Sopenharmony_ci#define OPCR_MPOa_RxRDY_FF          (0x7 << 0)
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ci#define OPCR_MPOb_RTSN              (0x0 << 4)
1938c2ecf20Sopenharmony_ci#define OPCR_MPOb_C_TO              (0x1 << 4)
1948c2ecf20Sopenharmony_ci#define OPCR_MPOb_TxC1X             (0x2 << 4)
1958c2ecf20Sopenharmony_ci#define OPCR_MPOb_TxC16X            (0x3 << 4)
1968c2ecf20Sopenharmony_ci#define OPCR_MPOb_RxC1X             (0x4 << 4)
1978c2ecf20Sopenharmony_ci#define OPCR_MPOb_RxC16X            (0x5 << 4)
1988c2ecf20Sopenharmony_ci#define OPCR_MPOb_TxRDY             (0x6 << 4)
1998c2ecf20Sopenharmony_ci#define OPCR_MPOb_RxRDY_FF          (0x7 << 4)
2008c2ecf20Sopenharmony_ci
2018c2ecf20Sopenharmony_ci#define OPCR_MPP_INPUT              (0x0 << 7)
2028c2ecf20Sopenharmony_ci#define OPCR_MPP_OUTPUT             (0x1 << 7)
2038c2ecf20Sopenharmony_ci
2048c2ecf20Sopenharmony_ci#define IMR_TxRDY_A                 (0x1 << 0)
2058c2ecf20Sopenharmony_ci#define IMR_RxRDY_FFULL_A           (0x1 << 1)
2068c2ecf20Sopenharmony_ci#define IMR_DELTA_BREAK_A           (0x1 << 2)
2078c2ecf20Sopenharmony_ci#define IMR_COUNTER_READY           (0x1 << 3)
2088c2ecf20Sopenharmony_ci#define IMR_TxRDY_B                 (0x1 << 4)
2098c2ecf20Sopenharmony_ci#define IMR_RxRDY_FFULL_B           (0x1 << 5)
2108c2ecf20Sopenharmony_ci#define IMR_DELTA_BREAK_B           (0x1 << 6)
2118c2ecf20Sopenharmony_ci#define IMR_INPUT_PORT_CHANGE       (0x1 << 7)
2128c2ecf20Sopenharmony_ci
2138c2ecf20Sopenharmony_ci#define ISR_TxRDY_A                 (0x1 << 0)
2148c2ecf20Sopenharmony_ci#define ISR_RxRDY_FFULL_A           (0x1 << 1)
2158c2ecf20Sopenharmony_ci#define ISR_DELTA_BREAK_A           (0x1 << 2)
2168c2ecf20Sopenharmony_ci#define ISR_COUNTER_READY           (0x1 << 3)
2178c2ecf20Sopenharmony_ci#define ISR_TxRDY_B                 (0x1 << 4)
2188c2ecf20Sopenharmony_ci#define ISR_RxRDY_FFULL_B           (0x1 << 5)
2198c2ecf20Sopenharmony_ci#define ISR_DELTA_BREAK_B           (0x1 << 6)
2208c2ecf20Sopenharmony_ci#define ISR_INPUT_PORT_CHANGE       (0x1 << 7)
2218c2ecf20Sopenharmony_ci
2228c2ecf20Sopenharmony_ci#define ACK_INT_REQ0			0
2238c2ecf20Sopenharmony_ci#define ACK_INT_REQ1			2
2248c2ecf20Sopenharmony_ci
2258c2ecf20Sopenharmony_ci#endif /* SCC2698_H_ */
226