18c2ecf20Sopenharmony_ci/* sbni.h: definitions for a Granch SBNI12 driver, version 5.0.0 28c2ecf20Sopenharmony_ci * Written 2001 Denis I.Timofeev (timofeev@granch.ru) 38c2ecf20Sopenharmony_ci * This file is distributed under the GNU GPL 48c2ecf20Sopenharmony_ci */ 58c2ecf20Sopenharmony_ci 68c2ecf20Sopenharmony_ci#ifndef SBNI_H 78c2ecf20Sopenharmony_ci#define SBNI_H 88c2ecf20Sopenharmony_ci 98c2ecf20Sopenharmony_ci#ifdef SBNI_DEBUG 108c2ecf20Sopenharmony_ci#define DP( A ) A 118c2ecf20Sopenharmony_ci#else 128c2ecf20Sopenharmony_ci#define DP( A ) 138c2ecf20Sopenharmony_ci#endif 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci/* We don't have official vendor id yet... */ 178c2ecf20Sopenharmony_ci#define SBNI_PCI_VENDOR 0x55 188c2ecf20Sopenharmony_ci#define SBNI_PCI_DEVICE 0x9f 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define ISA_MODE 0x00 218c2ecf20Sopenharmony_ci#define PCI_MODE 0x01 228c2ecf20Sopenharmony_ci 238c2ecf20Sopenharmony_ci#define SBNI_IO_EXTENT 4 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_cienum sbni_reg { 268c2ecf20Sopenharmony_ci CSR0 = 0, 278c2ecf20Sopenharmony_ci CSR1 = 1, 288c2ecf20Sopenharmony_ci DAT = 2 298c2ecf20Sopenharmony_ci}; 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ci/* CSR0 mapping */ 328c2ecf20Sopenharmony_cienum { 338c2ecf20Sopenharmony_ci BU_EMP = 0x02, 348c2ecf20Sopenharmony_ci RC_CHK = 0x04, 358c2ecf20Sopenharmony_ci CT_ZER = 0x08, 368c2ecf20Sopenharmony_ci TR_REQ = 0x10, 378c2ecf20Sopenharmony_ci TR_RDY = 0x20, 388c2ecf20Sopenharmony_ci EN_INT = 0x40, 398c2ecf20Sopenharmony_ci RC_RDY = 0x80 408c2ecf20Sopenharmony_ci}; 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* CSR1 mapping */ 448c2ecf20Sopenharmony_ci#define PR_RES 0x80 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_cistruct sbni_csr1 { 478c2ecf20Sopenharmony_ci#ifdef __LITTLE_ENDIAN_BITFIELD 488c2ecf20Sopenharmony_ci u8 rxl : 5; 498c2ecf20Sopenharmony_ci u8 rate : 2; 508c2ecf20Sopenharmony_ci u8 : 1; 518c2ecf20Sopenharmony_ci#else 528c2ecf20Sopenharmony_ci u8 : 1; 538c2ecf20Sopenharmony_ci u8 rate : 2; 548c2ecf20Sopenharmony_ci u8 rxl : 5; 558c2ecf20Sopenharmony_ci#endif 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci/* fields in frame header */ 598c2ecf20Sopenharmony_ci#define FRAME_ACK_MASK (unsigned short)0x7000 608c2ecf20Sopenharmony_ci#define FRAME_LEN_MASK (unsigned short)0x03FF 618c2ecf20Sopenharmony_ci#define FRAME_FIRST (unsigned short)0x8000 628c2ecf20Sopenharmony_ci#define FRAME_RETRY (unsigned short)0x0800 638c2ecf20Sopenharmony_ci 648c2ecf20Sopenharmony_ci#define FRAME_SENT_BAD (unsigned short)0x4000 658c2ecf20Sopenharmony_ci#define FRAME_SENT_OK (unsigned short)0x3000 668c2ecf20Sopenharmony_ci 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* state flags */ 698c2ecf20Sopenharmony_cienum { 708c2ecf20Sopenharmony_ci FL_WAIT_ACK = 0x01, 718c2ecf20Sopenharmony_ci FL_NEED_RESEND = 0x02, 728c2ecf20Sopenharmony_ci FL_PREV_OK = 0x04, 738c2ecf20Sopenharmony_ci FL_SLOW_MODE = 0x08, 748c2ecf20Sopenharmony_ci FL_SECONDARY = 0x10, 758c2ecf20Sopenharmony_ci#ifdef CONFIG_SBNI_MULTILINE 768c2ecf20Sopenharmony_ci FL_SLAVE = 0x20, 778c2ecf20Sopenharmony_ci#endif 788c2ecf20Sopenharmony_ci FL_LINE_DOWN = 0x40 798c2ecf20Sopenharmony_ci}; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_cienum { 838c2ecf20Sopenharmony_ci DEFAULT_IOBASEADDR = 0x210, 848c2ecf20Sopenharmony_ci DEFAULT_INTERRUPTNUMBER = 5, 858c2ecf20Sopenharmony_ci DEFAULT_RATE = 0, 868c2ecf20Sopenharmony_ci DEFAULT_FRAME_LEN = 1012 878c2ecf20Sopenharmony_ci}; 888c2ecf20Sopenharmony_ci 898c2ecf20Sopenharmony_ci#define DEF_RXL_DELTA -1 908c2ecf20Sopenharmony_ci#define DEF_RXL 0xf 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define SBNI_SIG 0x5a 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_ci#define SBNI_MIN_LEN 60 /* Shortest Ethernet frame without FCS */ 958c2ecf20Sopenharmony_ci#define SBNI_MAX_FRAME 1023 968c2ecf20Sopenharmony_ci#define ETHER_MAX_LEN 1518 978c2ecf20Sopenharmony_ci 988c2ecf20Sopenharmony_ci#define SBNI_TIMEOUT (HZ/10) 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci#define TR_ERROR_COUNT 32 1018c2ecf20Sopenharmony_ci#define CHANGE_LEVEL_START_TICKS 4 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci#define SBNI_MAX_NUM_CARDS 16 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci/* internal SBNI-specific statistics */ 1068c2ecf20Sopenharmony_cistruct sbni_in_stats { 1078c2ecf20Sopenharmony_ci u32 all_rx_number; 1088c2ecf20Sopenharmony_ci u32 bad_rx_number; 1098c2ecf20Sopenharmony_ci u32 timeout_number; 1108c2ecf20Sopenharmony_ci u32 all_tx_number; 1118c2ecf20Sopenharmony_ci u32 resend_tx_number; 1128c2ecf20Sopenharmony_ci}; 1138c2ecf20Sopenharmony_ci 1148c2ecf20Sopenharmony_ci/* SBNI ioctl params */ 1158c2ecf20Sopenharmony_ci#define SIOCDEVGETINSTATS SIOCDEVPRIVATE 1168c2ecf20Sopenharmony_ci#define SIOCDEVRESINSTATS SIOCDEVPRIVATE+1 1178c2ecf20Sopenharmony_ci#define SIOCDEVGHWSTATE SIOCDEVPRIVATE+2 1188c2ecf20Sopenharmony_ci#define SIOCDEVSHWSTATE SIOCDEVPRIVATE+3 1198c2ecf20Sopenharmony_ci#define SIOCDEVENSLAVE SIOCDEVPRIVATE+4 1208c2ecf20Sopenharmony_ci#define SIOCDEVEMANSIPATE SIOCDEVPRIVATE+5 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci/* data packet for SIOCDEVGHWSTATE/SIOCDEVSHWSTATE ioctl requests */ 1248c2ecf20Sopenharmony_cistruct sbni_flags { 1258c2ecf20Sopenharmony_ci u32 rxl : 4; 1268c2ecf20Sopenharmony_ci u32 rate : 2; 1278c2ecf20Sopenharmony_ci u32 fixed_rxl : 1; 1288c2ecf20Sopenharmony_ci u32 slow_mode : 1; 1298c2ecf20Sopenharmony_ci u32 mac_addr : 24; 1308c2ecf20Sopenharmony_ci}; 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci/* 1338c2ecf20Sopenharmony_ci * CRC-32 stuff 1348c2ecf20Sopenharmony_ci */ 1358c2ecf20Sopenharmony_ci#define CRC32(c,crc) (crc32tab[((size_t)(crc) ^ (c)) & 0xff] ^ (((crc) >> 8) & 0x00FFFFFF)) 1368c2ecf20Sopenharmony_ci /* CRC generator 0xEDB88320 */ 1378c2ecf20Sopenharmony_ci /* CRC remainder 0x2144DF1C */ 1388c2ecf20Sopenharmony_ci /* CRC initial value 0x00000000 */ 1398c2ecf20Sopenharmony_ci#define CRC32_REMAINDER 0x2144DF1C 1408c2ecf20Sopenharmony_ci#define CRC32_INITIAL 0x00000000 1418c2ecf20Sopenharmony_ci 1428c2ecf20Sopenharmony_ci#ifndef __initdata 1438c2ecf20Sopenharmony_ci#define __initdata 1448c2ecf20Sopenharmony_ci#endif 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_ci#endif 1478c2ecf20Sopenharmony_ci 148