18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * specific defines for CCD's HFC 2BDS0 PCI chips 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Author Werner Cornelius (werner@isdn4linux.de) 68c2ecf20Sopenharmony_ci * 78c2ecf20Sopenharmony_ci * Copyright 1999 by Werner Cornelius (werner@isdn4linux.de) 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_ci/* 118c2ecf20Sopenharmony_ci * thresholds for transparent B-channel mode 128c2ecf20Sopenharmony_ci * change mask and threshold simultaneously 138c2ecf20Sopenharmony_ci */ 148c2ecf20Sopenharmony_ci#define HFCPCI_BTRANS_THRESHOLD 128 158c2ecf20Sopenharmony_ci#define HFCPCI_FILLEMPTY 64 168c2ecf20Sopenharmony_ci#define HFCPCI_BTRANS_THRESMASK 0x00 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci/* defines for PCI config */ 198c2ecf20Sopenharmony_ci#define PCI_ENA_MEMIO 0x02 208c2ecf20Sopenharmony_ci#define PCI_ENA_MASTER 0x04 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* GCI/IOM bus monitor registers */ 238c2ecf20Sopenharmony_ci#define HCFPCI_C_I 0x08 248c2ecf20Sopenharmony_ci#define HFCPCI_TRxR 0x0C 258c2ecf20Sopenharmony_ci#define HFCPCI_MON1_D 0x28 268c2ecf20Sopenharmony_ci#define HFCPCI_MON2_D 0x2C 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_ci/* GCI/IOM bus timeslot registers */ 298c2ecf20Sopenharmony_ci#define HFCPCI_B1_SSL 0x80 308c2ecf20Sopenharmony_ci#define HFCPCI_B2_SSL 0x84 318c2ecf20Sopenharmony_ci#define HFCPCI_AUX1_SSL 0x88 328c2ecf20Sopenharmony_ci#define HFCPCI_AUX2_SSL 0x8C 338c2ecf20Sopenharmony_ci#define HFCPCI_B1_RSL 0x90 348c2ecf20Sopenharmony_ci#define HFCPCI_B2_RSL 0x94 358c2ecf20Sopenharmony_ci#define HFCPCI_AUX1_RSL 0x98 368c2ecf20Sopenharmony_ci#define HFCPCI_AUX2_RSL 0x9C 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci/* GCI/IOM bus data registers */ 398c2ecf20Sopenharmony_ci#define HFCPCI_B1_D 0xA0 408c2ecf20Sopenharmony_ci#define HFCPCI_B2_D 0xA4 418c2ecf20Sopenharmony_ci#define HFCPCI_AUX1_D 0xA8 428c2ecf20Sopenharmony_ci#define HFCPCI_AUX2_D 0xAC 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* GCI/IOM bus configuration registers */ 458c2ecf20Sopenharmony_ci#define HFCPCI_MST_EMOD 0xB4 468c2ecf20Sopenharmony_ci#define HFCPCI_MST_MODE 0xB8 478c2ecf20Sopenharmony_ci#define HFCPCI_CONNECT 0xBC 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci/* Interrupt and status registers */ 518c2ecf20Sopenharmony_ci#define HFCPCI_FIFO_EN 0x44 528c2ecf20Sopenharmony_ci#define HFCPCI_TRM 0x48 538c2ecf20Sopenharmony_ci#define HFCPCI_B_MODE 0x4C 548c2ecf20Sopenharmony_ci#define HFCPCI_CHIP_ID 0x58 558c2ecf20Sopenharmony_ci#define HFCPCI_CIRM 0x60 568c2ecf20Sopenharmony_ci#define HFCPCI_CTMT 0x64 578c2ecf20Sopenharmony_ci#define HFCPCI_INT_M1 0x68 588c2ecf20Sopenharmony_ci#define HFCPCI_INT_M2 0x6C 598c2ecf20Sopenharmony_ci#define HFCPCI_INT_S1 0x78 608c2ecf20Sopenharmony_ci#define HFCPCI_INT_S2 0x7C 618c2ecf20Sopenharmony_ci#define HFCPCI_STATUS 0x70 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_ci/* S/T section registers */ 648c2ecf20Sopenharmony_ci#define HFCPCI_STATES 0xC0 658c2ecf20Sopenharmony_ci#define HFCPCI_SCTRL 0xC4 668c2ecf20Sopenharmony_ci#define HFCPCI_SCTRL_E 0xC8 678c2ecf20Sopenharmony_ci#define HFCPCI_SCTRL_R 0xCC 688c2ecf20Sopenharmony_ci#define HFCPCI_SQ 0xD0 698c2ecf20Sopenharmony_ci#define HFCPCI_CLKDEL 0xDC 708c2ecf20Sopenharmony_ci#define HFCPCI_B1_REC 0xF0 718c2ecf20Sopenharmony_ci#define HFCPCI_B1_SEND 0xF0 728c2ecf20Sopenharmony_ci#define HFCPCI_B2_REC 0xF4 738c2ecf20Sopenharmony_ci#define HFCPCI_B2_SEND 0xF4 748c2ecf20Sopenharmony_ci#define HFCPCI_D_REC 0xF8 758c2ecf20Sopenharmony_ci#define HFCPCI_D_SEND 0xF8 768c2ecf20Sopenharmony_ci#define HFCPCI_E_REC 0xFC 778c2ecf20Sopenharmony_ci 788c2ecf20Sopenharmony_ci 798c2ecf20Sopenharmony_ci/* bits in status register (READ) */ 808c2ecf20Sopenharmony_ci#define HFCPCI_PCI_PROC 0x02 818c2ecf20Sopenharmony_ci#define HFCPCI_NBUSY 0x04 828c2ecf20Sopenharmony_ci#define HFCPCI_TIMER_ELAP 0x10 838c2ecf20Sopenharmony_ci#define HFCPCI_STATINT 0x20 848c2ecf20Sopenharmony_ci#define HFCPCI_FRAMEINT 0x40 858c2ecf20Sopenharmony_ci#define HFCPCI_ANYINT 0x80 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci/* bits in CTMT (Write) */ 888c2ecf20Sopenharmony_ci#define HFCPCI_CLTIMER 0x80 898c2ecf20Sopenharmony_ci#define HFCPCI_TIM3_125 0x04 908c2ecf20Sopenharmony_ci#define HFCPCI_TIM25 0x10 918c2ecf20Sopenharmony_ci#define HFCPCI_TIM50 0x14 928c2ecf20Sopenharmony_ci#define HFCPCI_TIM400 0x18 938c2ecf20Sopenharmony_ci#define HFCPCI_TIM800 0x1C 948c2ecf20Sopenharmony_ci#define HFCPCI_AUTO_TIMER 0x20 958c2ecf20Sopenharmony_ci#define HFCPCI_TRANSB2 0x02 968c2ecf20Sopenharmony_ci#define HFCPCI_TRANSB1 0x01 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci/* bits in CIRM (Write) */ 998c2ecf20Sopenharmony_ci#define HFCPCI_AUX_MSK 0x07 1008c2ecf20Sopenharmony_ci#define HFCPCI_RESET 0x08 1018c2ecf20Sopenharmony_ci#define HFCPCI_B1_REV 0x40 1028c2ecf20Sopenharmony_ci#define HFCPCI_B2_REV 0x80 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci/* bits in INT_M1 and INT_S1 */ 1058c2ecf20Sopenharmony_ci#define HFCPCI_INTS_B1TRANS 0x01 1068c2ecf20Sopenharmony_ci#define HFCPCI_INTS_B2TRANS 0x02 1078c2ecf20Sopenharmony_ci#define HFCPCI_INTS_DTRANS 0x04 1088c2ecf20Sopenharmony_ci#define HFCPCI_INTS_B1REC 0x08 1098c2ecf20Sopenharmony_ci#define HFCPCI_INTS_B2REC 0x10 1108c2ecf20Sopenharmony_ci#define HFCPCI_INTS_DREC 0x20 1118c2ecf20Sopenharmony_ci#define HFCPCI_INTS_L1STATE 0x40 1128c2ecf20Sopenharmony_ci#define HFCPCI_INTS_TIMER 0x80 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci/* bits in INT_M2 */ 1158c2ecf20Sopenharmony_ci#define HFCPCI_PROC_TRANS 0x01 1168c2ecf20Sopenharmony_ci#define HFCPCI_GCI_I_CHG 0x02 1178c2ecf20Sopenharmony_ci#define HFCPCI_GCI_MON_REC 0x04 1188c2ecf20Sopenharmony_ci#define HFCPCI_IRQ_ENABLE 0x08 1198c2ecf20Sopenharmony_ci#define HFCPCI_PMESEL 0x80 1208c2ecf20Sopenharmony_ci 1218c2ecf20Sopenharmony_ci/* bits in STATES */ 1228c2ecf20Sopenharmony_ci#define HFCPCI_STATE_MSK 0x0F 1238c2ecf20Sopenharmony_ci#define HFCPCI_LOAD_STATE 0x10 1248c2ecf20Sopenharmony_ci#define HFCPCI_ACTIVATE 0x20 1258c2ecf20Sopenharmony_ci#define HFCPCI_DO_ACTION 0x40 1268c2ecf20Sopenharmony_ci#define HFCPCI_NT_G2_G3 0x80 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_ci/* bits in HFCD_MST_MODE */ 1298c2ecf20Sopenharmony_ci#define HFCPCI_MASTER 0x01 1308c2ecf20Sopenharmony_ci#define HFCPCI_SLAVE 0x00 1318c2ecf20Sopenharmony_ci#define HFCPCI_F0IO_POSITIV 0x02 1328c2ecf20Sopenharmony_ci#define HFCPCI_F0_NEGATIV 0x04 1338c2ecf20Sopenharmony_ci#define HFCPCI_F0_2C4 0x08 1348c2ecf20Sopenharmony_ci/* remaining bits are for codecs control */ 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci/* bits in HFCD_SCTRL */ 1378c2ecf20Sopenharmony_ci#define SCTRL_B1_ENA 0x01 1388c2ecf20Sopenharmony_ci#define SCTRL_B2_ENA 0x02 1398c2ecf20Sopenharmony_ci#define SCTRL_MODE_TE 0x00 1408c2ecf20Sopenharmony_ci#define SCTRL_MODE_NT 0x04 1418c2ecf20Sopenharmony_ci#define SCTRL_LOW_PRIO 0x08 1428c2ecf20Sopenharmony_ci#define SCTRL_SQ_ENA 0x10 1438c2ecf20Sopenharmony_ci#define SCTRL_TEST 0x20 1448c2ecf20Sopenharmony_ci#define SCTRL_NONE_CAP 0x40 1458c2ecf20Sopenharmony_ci#define SCTRL_PWR_DOWN 0x80 1468c2ecf20Sopenharmony_ci 1478c2ecf20Sopenharmony_ci/* bits in SCTRL_E */ 1488c2ecf20Sopenharmony_ci#define HFCPCI_AUTO_AWAKE 0x01 1498c2ecf20Sopenharmony_ci#define HFCPCI_DBIT_1 0x04 1508c2ecf20Sopenharmony_ci#define HFCPCI_IGNORE_COL 0x08 1518c2ecf20Sopenharmony_ci#define HFCPCI_CHG_B1_B2 0x80 1528c2ecf20Sopenharmony_ci 1538c2ecf20Sopenharmony_ci/* bits in FIFO_EN register */ 1548c2ecf20Sopenharmony_ci#define HFCPCI_FIFOEN_B1 0x03 1558c2ecf20Sopenharmony_ci#define HFCPCI_FIFOEN_B2 0x0C 1568c2ecf20Sopenharmony_ci#define HFCPCI_FIFOEN_DTX 0x10 1578c2ecf20Sopenharmony_ci#define HFCPCI_FIFOEN_B1TX 0x01 1588c2ecf20Sopenharmony_ci#define HFCPCI_FIFOEN_B1RX 0x02 1598c2ecf20Sopenharmony_ci#define HFCPCI_FIFOEN_B2TX 0x04 1608c2ecf20Sopenharmony_ci#define HFCPCI_FIFOEN_B2RX 0x08 1618c2ecf20Sopenharmony_ci 1628c2ecf20Sopenharmony_ci 1638c2ecf20Sopenharmony_ci/* definitions of fifo memory area */ 1648c2ecf20Sopenharmony_ci#define MAX_D_FRAMES 15 1658c2ecf20Sopenharmony_ci#define MAX_B_FRAMES 31 1668c2ecf20Sopenharmony_ci#define B_SUB_VAL 0x200 1678c2ecf20Sopenharmony_ci#define B_FIFO_SIZE (0x2000 - B_SUB_VAL) 1688c2ecf20Sopenharmony_ci#define D_FIFO_SIZE 512 1698c2ecf20Sopenharmony_ci#define D_FREG_MASK 0xF 1708c2ecf20Sopenharmony_ci 1718c2ecf20Sopenharmony_cistruct zt { 1728c2ecf20Sopenharmony_ci __le16 z1; /* Z1 pointer 16 Bit */ 1738c2ecf20Sopenharmony_ci __le16 z2; /* Z2 pointer 16 Bit */ 1748c2ecf20Sopenharmony_ci}; 1758c2ecf20Sopenharmony_ci 1768c2ecf20Sopenharmony_cistruct dfifo { 1778c2ecf20Sopenharmony_ci u_char data[D_FIFO_SIZE]; /* FIFO data space */ 1788c2ecf20Sopenharmony_ci u_char fill1[0x20A0 - D_FIFO_SIZE]; /* reserved, do not use */ 1798c2ecf20Sopenharmony_ci u_char f1, f2; /* f pointers */ 1808c2ecf20Sopenharmony_ci u_char fill2[0x20C0 - 0x20A2]; /* reserved, do not use */ 1818c2ecf20Sopenharmony_ci /* mask index with D_FREG_MASK for access */ 1828c2ecf20Sopenharmony_ci struct zt za[MAX_D_FRAMES + 1]; 1838c2ecf20Sopenharmony_ci u_char fill3[0x4000 - 0x2100]; /* align 16K */ 1848c2ecf20Sopenharmony_ci}; 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_cistruct bzfifo { 1878c2ecf20Sopenharmony_ci struct zt za[MAX_B_FRAMES + 1]; /* only range 0x0..0x1F allowed */ 1888c2ecf20Sopenharmony_ci u_char f1, f2; /* f pointers */ 1898c2ecf20Sopenharmony_ci u_char fill[0x2100 - 0x2082]; /* alignment */ 1908c2ecf20Sopenharmony_ci}; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci 1938c2ecf20Sopenharmony_ciunion fifo_area { 1948c2ecf20Sopenharmony_ci struct { 1958c2ecf20Sopenharmony_ci struct dfifo d_tx; /* D-send channel */ 1968c2ecf20Sopenharmony_ci struct dfifo d_rx; /* D-receive channel */ 1978c2ecf20Sopenharmony_ci } d_chan; 1988c2ecf20Sopenharmony_ci struct { 1998c2ecf20Sopenharmony_ci u_char fill1[0x200]; 2008c2ecf20Sopenharmony_ci u_char txdat_b1[B_FIFO_SIZE]; 2018c2ecf20Sopenharmony_ci struct bzfifo txbz_b1; 2028c2ecf20Sopenharmony_ci struct bzfifo txbz_b2; 2038c2ecf20Sopenharmony_ci u_char txdat_b2[B_FIFO_SIZE]; 2048c2ecf20Sopenharmony_ci u_char fill2[D_FIFO_SIZE]; 2058c2ecf20Sopenharmony_ci u_char rxdat_b1[B_FIFO_SIZE]; 2068c2ecf20Sopenharmony_ci struct bzfifo rxbz_b1; 2078c2ecf20Sopenharmony_ci struct bzfifo rxbz_b2; 2088c2ecf20Sopenharmony_ci u_char rxdat_b2[B_FIFO_SIZE]; 2098c2ecf20Sopenharmony_ci } b_chans; 2108c2ecf20Sopenharmony_ci u_char fill[32768]; 2118c2ecf20Sopenharmony_ci}; 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci#define Write_hfc(a, b, c) (writeb(c, (a->hw.pci_io) + b)) 2148c2ecf20Sopenharmony_ci#define Read_hfc(a, b) (readb((a->hw.pci_io) + b)) 215