18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci#ifndef MOXA_H_FILE 38c2ecf20Sopenharmony_ci#define MOXA_H_FILE 48c2ecf20Sopenharmony_ci 58c2ecf20Sopenharmony_ci#define MOXA 0x400 68c2ecf20Sopenharmony_ci#define MOXA_GET_IQUEUE (MOXA + 1) /* get input buffered count */ 78c2ecf20Sopenharmony_ci#define MOXA_GET_OQUEUE (MOXA + 2) /* get output buffered count */ 88c2ecf20Sopenharmony_ci#define MOXA_GETDATACOUNT (MOXA + 23) 98c2ecf20Sopenharmony_ci#define MOXA_GET_IOQUEUE (MOXA + 27) 108c2ecf20Sopenharmony_ci#define MOXA_FLUSH_QUEUE (MOXA + 28) 118c2ecf20Sopenharmony_ci#define MOXA_GETMSTATUS (MOXA + 65) 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * System Configuration 158c2ecf20Sopenharmony_ci */ 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define Magic_code 0x404 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* 208c2ecf20Sopenharmony_ci * for C218 BIOS initialization 218c2ecf20Sopenharmony_ci */ 228c2ecf20Sopenharmony_ci#define C218_ConfBase 0x800 238c2ecf20Sopenharmony_ci#define C218_status (C218_ConfBase + 0) /* BIOS running status */ 248c2ecf20Sopenharmony_ci#define C218_diag (C218_ConfBase + 2) /* diagnostic status */ 258c2ecf20Sopenharmony_ci#define C218_key (C218_ConfBase + 4) /* WORD (0x218 for C218) */ 268c2ecf20Sopenharmony_ci#define C218DLoad_len (C218_ConfBase + 6) /* WORD */ 278c2ecf20Sopenharmony_ci#define C218check_sum (C218_ConfBase + 8) /* BYTE */ 288c2ecf20Sopenharmony_ci#define C218chksum_ok (C218_ConfBase + 0x0a) /* BYTE (1:ok) */ 298c2ecf20Sopenharmony_ci#define C218_TestRx (C218_ConfBase + 0x10) /* 8 bytes for 8 ports */ 308c2ecf20Sopenharmony_ci#define C218_TestTx (C218_ConfBase + 0x18) /* 8 bytes for 8 ports */ 318c2ecf20Sopenharmony_ci#define C218_RXerr (C218_ConfBase + 0x20) /* 8 bytes for 8 ports */ 328c2ecf20Sopenharmony_ci#define C218_ErrFlag (C218_ConfBase + 0x28) /* 8 bytes for 8 ports */ 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ci#define C218_LoadBuf 0x0F00 358c2ecf20Sopenharmony_ci#define C218_KeyCode 0x218 368c2ecf20Sopenharmony_ci#define CP204J_KeyCode 0x204 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* 398c2ecf20Sopenharmony_ci * for C320 BIOS initialization 408c2ecf20Sopenharmony_ci */ 418c2ecf20Sopenharmony_ci#define C320_ConfBase 0x800 428c2ecf20Sopenharmony_ci#define C320_LoadBuf 0x0f00 438c2ecf20Sopenharmony_ci#define STS_init 0x05 /* for C320_status */ 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci#define C320_status C320_ConfBase + 0 /* BIOS running status */ 468c2ecf20Sopenharmony_ci#define C320_diag C320_ConfBase + 2 /* diagnostic status */ 478c2ecf20Sopenharmony_ci#define C320_key C320_ConfBase + 4 /* WORD (0320H for C320) */ 488c2ecf20Sopenharmony_ci#define C320DLoad_len C320_ConfBase + 6 /* WORD */ 498c2ecf20Sopenharmony_ci#define C320check_sum C320_ConfBase + 8 /* WORD */ 508c2ecf20Sopenharmony_ci#define C320chksum_ok C320_ConfBase + 0x0a /* WORD (1:ok) */ 518c2ecf20Sopenharmony_ci#define C320bapi_len C320_ConfBase + 0x0c /* WORD */ 528c2ecf20Sopenharmony_ci#define C320UART_no C320_ConfBase + 0x0e /* WORD */ 538c2ecf20Sopenharmony_ci 548c2ecf20Sopenharmony_ci#define C320_KeyCode 0x320 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_ci#define FixPage_addr 0x0000 /* starting addr of static page */ 578c2ecf20Sopenharmony_ci#define DynPage_addr 0x2000 /* starting addr of dynamic page */ 588c2ecf20Sopenharmony_ci#define C218_start 0x3000 /* starting addr of C218 BIOS prg */ 598c2ecf20Sopenharmony_ci#define Control_reg 0x1ff0 /* select page and reset control */ 608c2ecf20Sopenharmony_ci#define HW_reset 0x80 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* 638c2ecf20Sopenharmony_ci * Function Codes 648c2ecf20Sopenharmony_ci */ 658c2ecf20Sopenharmony_ci#define FC_CardReset 0x80 668c2ecf20Sopenharmony_ci#define FC_ChannelReset 1 /* C320 firmware not supported */ 678c2ecf20Sopenharmony_ci#define FC_EnableCH 2 688c2ecf20Sopenharmony_ci#define FC_DisableCH 3 698c2ecf20Sopenharmony_ci#define FC_SetParam 4 708c2ecf20Sopenharmony_ci#define FC_SetMode 5 718c2ecf20Sopenharmony_ci#define FC_SetRate 6 728c2ecf20Sopenharmony_ci#define FC_LineControl 7 738c2ecf20Sopenharmony_ci#define FC_LineStatus 8 748c2ecf20Sopenharmony_ci#define FC_XmitControl 9 758c2ecf20Sopenharmony_ci#define FC_FlushQueue 10 768c2ecf20Sopenharmony_ci#define FC_SendBreak 11 778c2ecf20Sopenharmony_ci#define FC_StopBreak 12 788c2ecf20Sopenharmony_ci#define FC_LoopbackON 13 798c2ecf20Sopenharmony_ci#define FC_LoopbackOFF 14 808c2ecf20Sopenharmony_ci#define FC_ClrIrqTable 15 818c2ecf20Sopenharmony_ci#define FC_SendXon 16 828c2ecf20Sopenharmony_ci#define FC_SetTermIrq 17 /* C320 firmware not supported */ 838c2ecf20Sopenharmony_ci#define FC_SetCntIrq 18 /* C320 firmware not supported */ 848c2ecf20Sopenharmony_ci#define FC_SetBreakIrq 19 858c2ecf20Sopenharmony_ci#define FC_SetLineIrq 20 868c2ecf20Sopenharmony_ci#define FC_SetFlowCtl 21 878c2ecf20Sopenharmony_ci#define FC_GenIrq 22 888c2ecf20Sopenharmony_ci#define FC_InCD180 23 898c2ecf20Sopenharmony_ci#define FC_OutCD180 24 908c2ecf20Sopenharmony_ci#define FC_InUARTreg 23 918c2ecf20Sopenharmony_ci#define FC_OutUARTreg 24 928c2ecf20Sopenharmony_ci#define FC_SetXonXoff 25 938c2ecf20Sopenharmony_ci#define FC_OutCD180CCR 26 948c2ecf20Sopenharmony_ci#define FC_ExtIQueue 27 958c2ecf20Sopenharmony_ci#define FC_ExtOQueue 28 968c2ecf20Sopenharmony_ci#define FC_ClrLineIrq 29 978c2ecf20Sopenharmony_ci#define FC_HWFlowCtl 30 988c2ecf20Sopenharmony_ci#define FC_GetClockRate 35 998c2ecf20Sopenharmony_ci#define FC_SetBaud 36 1008c2ecf20Sopenharmony_ci#define FC_SetDataMode 41 1018c2ecf20Sopenharmony_ci#define FC_GetCCSR 43 1028c2ecf20Sopenharmony_ci#define FC_GetDataError 45 1038c2ecf20Sopenharmony_ci#define FC_RxControl 50 1048c2ecf20Sopenharmony_ci#define FC_ImmSend 51 1058c2ecf20Sopenharmony_ci#define FC_SetXonState 52 1068c2ecf20Sopenharmony_ci#define FC_SetXoffState 53 1078c2ecf20Sopenharmony_ci#define FC_SetRxFIFOTrig 54 1088c2ecf20Sopenharmony_ci#define FC_SetTxFIFOCnt 55 1098c2ecf20Sopenharmony_ci#define FC_UnixRate 56 1108c2ecf20Sopenharmony_ci#define FC_UnixResetTimer 57 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci#define RxFIFOTrig1 0 1138c2ecf20Sopenharmony_ci#define RxFIFOTrig4 1 1148c2ecf20Sopenharmony_ci#define RxFIFOTrig8 2 1158c2ecf20Sopenharmony_ci#define RxFIFOTrig14 3 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci/* 1188c2ecf20Sopenharmony_ci * Dual-Ported RAM 1198c2ecf20Sopenharmony_ci */ 1208c2ecf20Sopenharmony_ci#define DRAM_global 0 1218c2ecf20Sopenharmony_ci#define INT_data (DRAM_global + 0) 1228c2ecf20Sopenharmony_ci#define Config_base (DRAM_global + 0x108) 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_ci#define IRQindex (INT_data + 0) 1258c2ecf20Sopenharmony_ci#define IRQpending (INT_data + 4) 1268c2ecf20Sopenharmony_ci#define IRQtable (INT_data + 8) 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci/* 1298c2ecf20Sopenharmony_ci * Interrupt Status 1308c2ecf20Sopenharmony_ci */ 1318c2ecf20Sopenharmony_ci#define IntrRx 0x01 /* receiver data O.K. */ 1328c2ecf20Sopenharmony_ci#define IntrTx 0x02 /* transmit buffer empty */ 1338c2ecf20Sopenharmony_ci#define IntrFunc 0x04 /* function complete */ 1348c2ecf20Sopenharmony_ci#define IntrBreak 0x08 /* received break */ 1358c2ecf20Sopenharmony_ci#define IntrLine 0x10 /* line status change 1368c2ecf20Sopenharmony_ci for transmitter */ 1378c2ecf20Sopenharmony_ci#define IntrIntr 0x20 /* received INTR code */ 1388c2ecf20Sopenharmony_ci#define IntrQuit 0x40 /* received QUIT code */ 1398c2ecf20Sopenharmony_ci#define IntrEOF 0x80 /* received EOF code */ 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci#define IntrRxTrigger 0x100 /* rx data count reach trigger value */ 1428c2ecf20Sopenharmony_ci#define IntrTxTrigger 0x200 /* tx data count below trigger value */ 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_ci#define Magic_no (Config_base + 0) 1458c2ecf20Sopenharmony_ci#define Card_model_no (Config_base + 2) 1468c2ecf20Sopenharmony_ci#define Total_ports (Config_base + 4) 1478c2ecf20Sopenharmony_ci#define Module_cnt (Config_base + 8) 1488c2ecf20Sopenharmony_ci#define Module_no (Config_base + 10) 1498c2ecf20Sopenharmony_ci#define Timer_10ms (Config_base + 14) 1508c2ecf20Sopenharmony_ci#define Disable_IRQ (Config_base + 20) 1518c2ecf20Sopenharmony_ci#define TMS320_PORT1 (Config_base + 22) 1528c2ecf20Sopenharmony_ci#define TMS320_PORT2 (Config_base + 24) 1538c2ecf20Sopenharmony_ci#define TMS320_CLOCK (Config_base + 26) 1548c2ecf20Sopenharmony_ci 1558c2ecf20Sopenharmony_ci/* 1568c2ecf20Sopenharmony_ci * DATA BUFFER in DRAM 1578c2ecf20Sopenharmony_ci */ 1588c2ecf20Sopenharmony_ci#define Extern_table 0x400 /* Base address of the external table 1598c2ecf20Sopenharmony_ci (24 words * 64) total 3K bytes 1608c2ecf20Sopenharmony_ci (24 words * 128) total 6K bytes */ 1618c2ecf20Sopenharmony_ci#define Extern_size 0x60 /* 96 bytes */ 1628c2ecf20Sopenharmony_ci#define RXrptr 0x00 /* read pointer for RX buffer */ 1638c2ecf20Sopenharmony_ci#define RXwptr 0x02 /* write pointer for RX buffer */ 1648c2ecf20Sopenharmony_ci#define TXrptr 0x04 /* read pointer for TX buffer */ 1658c2ecf20Sopenharmony_ci#define TXwptr 0x06 /* write pointer for TX buffer */ 1668c2ecf20Sopenharmony_ci#define HostStat 0x08 /* IRQ flag and general flag */ 1678c2ecf20Sopenharmony_ci#define FlagStat 0x0A 1688c2ecf20Sopenharmony_ci#define FlowControl 0x0C /* B7 B6 B5 B4 B3 B2 B1 B0 */ 1698c2ecf20Sopenharmony_ci /* x x x x | | | | */ 1708c2ecf20Sopenharmony_ci /* | | | + CTS flow */ 1718c2ecf20Sopenharmony_ci /* | | +--- RTS flow */ 1728c2ecf20Sopenharmony_ci /* | +------ TX Xon/Xoff */ 1738c2ecf20Sopenharmony_ci /* +--------- RX Xon/Xoff */ 1748c2ecf20Sopenharmony_ci#define Break_cnt 0x0E /* received break count */ 1758c2ecf20Sopenharmony_ci#define CD180TXirq 0x10 /* if non-0: enable TX irq */ 1768c2ecf20Sopenharmony_ci#define RX_mask 0x12 1778c2ecf20Sopenharmony_ci#define TX_mask 0x14 1788c2ecf20Sopenharmony_ci#define Ofs_rxb 0x16 1798c2ecf20Sopenharmony_ci#define Ofs_txb 0x18 1808c2ecf20Sopenharmony_ci#define Page_rxb 0x1A 1818c2ecf20Sopenharmony_ci#define Page_txb 0x1C 1828c2ecf20Sopenharmony_ci#define EndPage_rxb 0x1E 1838c2ecf20Sopenharmony_ci#define EndPage_txb 0x20 1848c2ecf20Sopenharmony_ci#define Data_error 0x22 1858c2ecf20Sopenharmony_ci#define RxTrigger 0x28 1868c2ecf20Sopenharmony_ci#define TxTrigger 0x2a 1878c2ecf20Sopenharmony_ci 1888c2ecf20Sopenharmony_ci#define rRXwptr 0x34 1898c2ecf20Sopenharmony_ci#define Low_water 0x36 1908c2ecf20Sopenharmony_ci 1918c2ecf20Sopenharmony_ci#define FuncCode 0x40 1928c2ecf20Sopenharmony_ci#define FuncArg 0x42 1938c2ecf20Sopenharmony_ci#define FuncArg1 0x44 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci#define C218rx_size 0x2000 /* 8K bytes */ 1968c2ecf20Sopenharmony_ci#define C218tx_size 0x8000 /* 32K bytes */ 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci#define C218rx_mask (C218rx_size - 1) 1998c2ecf20Sopenharmony_ci#define C218tx_mask (C218tx_size - 1) 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci#define C320p8rx_size 0x2000 2028c2ecf20Sopenharmony_ci#define C320p8tx_size 0x8000 2038c2ecf20Sopenharmony_ci#define C320p8rx_mask (C320p8rx_size - 1) 2048c2ecf20Sopenharmony_ci#define C320p8tx_mask (C320p8tx_size - 1) 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci#define C320p16rx_size 0x2000 2078c2ecf20Sopenharmony_ci#define C320p16tx_size 0x4000 2088c2ecf20Sopenharmony_ci#define C320p16rx_mask (C320p16rx_size - 1) 2098c2ecf20Sopenharmony_ci#define C320p16tx_mask (C320p16tx_size - 1) 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci#define C320p24rx_size 0x2000 2128c2ecf20Sopenharmony_ci#define C320p24tx_size 0x2000 2138c2ecf20Sopenharmony_ci#define C320p24rx_mask (C320p24rx_size - 1) 2148c2ecf20Sopenharmony_ci#define C320p24tx_mask (C320p24tx_size - 1) 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci#define C320p32rx_size 0x1000 2178c2ecf20Sopenharmony_ci#define C320p32tx_size 0x1000 2188c2ecf20Sopenharmony_ci#define C320p32rx_mask (C320p32rx_size - 1) 2198c2ecf20Sopenharmony_ci#define C320p32tx_mask (C320p32tx_size - 1) 2208c2ecf20Sopenharmony_ci 2218c2ecf20Sopenharmony_ci#define Page_size 0x2000U 2228c2ecf20Sopenharmony_ci#define Page_mask (Page_size - 1) 2238c2ecf20Sopenharmony_ci#define C218rx_spage 3 2248c2ecf20Sopenharmony_ci#define C218tx_spage 4 2258c2ecf20Sopenharmony_ci#define C218rx_pageno 1 2268c2ecf20Sopenharmony_ci#define C218tx_pageno 4 2278c2ecf20Sopenharmony_ci#define C218buf_pageno 5 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci#define C320p8rx_spage 3 2308c2ecf20Sopenharmony_ci#define C320p8tx_spage 4 2318c2ecf20Sopenharmony_ci#define C320p8rx_pgno 1 2328c2ecf20Sopenharmony_ci#define C320p8tx_pgno 4 2338c2ecf20Sopenharmony_ci#define C320p8buf_pgno 5 2348c2ecf20Sopenharmony_ci 2358c2ecf20Sopenharmony_ci#define C320p16rx_spage 3 2368c2ecf20Sopenharmony_ci#define C320p16tx_spage 4 2378c2ecf20Sopenharmony_ci#define C320p16rx_pgno 1 2388c2ecf20Sopenharmony_ci#define C320p16tx_pgno 2 2398c2ecf20Sopenharmony_ci#define C320p16buf_pgno 3 2408c2ecf20Sopenharmony_ci 2418c2ecf20Sopenharmony_ci#define C320p24rx_spage 3 2428c2ecf20Sopenharmony_ci#define C320p24tx_spage 4 2438c2ecf20Sopenharmony_ci#define C320p24rx_pgno 1 2448c2ecf20Sopenharmony_ci#define C320p24tx_pgno 1 2458c2ecf20Sopenharmony_ci#define C320p24buf_pgno 2 2468c2ecf20Sopenharmony_ci 2478c2ecf20Sopenharmony_ci#define C320p32rx_spage 3 2488c2ecf20Sopenharmony_ci#define C320p32tx_ofs C320p32rx_size 2498c2ecf20Sopenharmony_ci#define C320p32tx_spage 3 2508c2ecf20Sopenharmony_ci#define C320p32buf_pgno 1 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci/* 2538c2ecf20Sopenharmony_ci * Host Status 2548c2ecf20Sopenharmony_ci */ 2558c2ecf20Sopenharmony_ci#define WakeupRx 0x01 2568c2ecf20Sopenharmony_ci#define WakeupTx 0x02 2578c2ecf20Sopenharmony_ci#define WakeupBreak 0x08 2588c2ecf20Sopenharmony_ci#define WakeupLine 0x10 2598c2ecf20Sopenharmony_ci#define WakeupIntr 0x20 2608c2ecf20Sopenharmony_ci#define WakeupQuit 0x40 2618c2ecf20Sopenharmony_ci#define WakeupEOF 0x80 /* used in VTIME control */ 2628c2ecf20Sopenharmony_ci#define WakeupRxTrigger 0x100 2638c2ecf20Sopenharmony_ci#define WakeupTxTrigger 0x200 2648c2ecf20Sopenharmony_ci/* 2658c2ecf20Sopenharmony_ci * Flag status 2668c2ecf20Sopenharmony_ci */ 2678c2ecf20Sopenharmony_ci#define Rx_over 0x01 2688c2ecf20Sopenharmony_ci#define Xoff_state 0x02 2698c2ecf20Sopenharmony_ci#define Tx_flowOff 0x04 2708c2ecf20Sopenharmony_ci#define Tx_enable 0x08 2718c2ecf20Sopenharmony_ci#define CTS_state 0x10 2728c2ecf20Sopenharmony_ci#define DSR_state 0x20 2738c2ecf20Sopenharmony_ci#define DCD_state 0x80 2748c2ecf20Sopenharmony_ci/* 2758c2ecf20Sopenharmony_ci * FlowControl 2768c2ecf20Sopenharmony_ci */ 2778c2ecf20Sopenharmony_ci#define CTS_FlowCtl 1 2788c2ecf20Sopenharmony_ci#define RTS_FlowCtl 2 2798c2ecf20Sopenharmony_ci#define Tx_FlowCtl 4 2808c2ecf20Sopenharmony_ci#define Rx_FlowCtl 8 2818c2ecf20Sopenharmony_ci#define IXM_IXANY 0x10 2828c2ecf20Sopenharmony_ci 2838c2ecf20Sopenharmony_ci#define LowWater 128 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci#define DTR_ON 1 2868c2ecf20Sopenharmony_ci#define RTS_ON 2 2878c2ecf20Sopenharmony_ci#define CTS_ON 1 2888c2ecf20Sopenharmony_ci#define DSR_ON 2 2898c2ecf20Sopenharmony_ci#define DCD_ON 8 2908c2ecf20Sopenharmony_ci 2918c2ecf20Sopenharmony_ci/* mode definition */ 2928c2ecf20Sopenharmony_ci#define MX_CS8 0x03 2938c2ecf20Sopenharmony_ci#define MX_CS7 0x02 2948c2ecf20Sopenharmony_ci#define MX_CS6 0x01 2958c2ecf20Sopenharmony_ci#define MX_CS5 0x00 2968c2ecf20Sopenharmony_ci 2978c2ecf20Sopenharmony_ci#define MX_STOP1 0x00 2988c2ecf20Sopenharmony_ci#define MX_STOP15 0x04 2998c2ecf20Sopenharmony_ci#define MX_STOP2 0x08 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_ci#define MX_PARNONE 0x00 3028c2ecf20Sopenharmony_ci#define MX_PAREVEN 0x40 3038c2ecf20Sopenharmony_ci#define MX_PARODD 0xC0 3048c2ecf20Sopenharmony_ci#define MX_PARMARK 0xA0 3058c2ecf20Sopenharmony_ci#define MX_PARSPACE 0x20 3068c2ecf20Sopenharmony_ci 3078c2ecf20Sopenharmony_ci#endif 308