18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/** 38c2ecf20Sopenharmony_ci * encx24j600_hw.h: Register definitions 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci */ 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ci#ifndef _ENCX24J600_HW_H 88c2ecf20Sopenharmony_ci#define _ENCX24J600_HW_H 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_cistruct encx24j600_context { 118c2ecf20Sopenharmony_ci struct spi_device *spi; 128c2ecf20Sopenharmony_ci struct regmap *regmap; 138c2ecf20Sopenharmony_ci struct regmap *phymap; 148c2ecf20Sopenharmony_ci struct mutex mutex; /* mutex to protect access to regmap */ 158c2ecf20Sopenharmony_ci int bank; 168c2ecf20Sopenharmony_ci}; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ciint devm_regmap_init_encx24j600(struct device *dev, 198c2ecf20Sopenharmony_ci struct encx24j600_context *ctx); 208c2ecf20Sopenharmony_ci 218c2ecf20Sopenharmony_ci/* Single-byte instructions */ 228c2ecf20Sopenharmony_ci#define BANK_SELECT(bank) (0xC0 | ((bank & (BANK_MASK >> BANK_SHIFT)) << 1)) 238c2ecf20Sopenharmony_ci#define B0SEL 0xC0 /* Bank 0 Select */ 248c2ecf20Sopenharmony_ci#define B1SEL 0xC2 /* Bank 1 Select */ 258c2ecf20Sopenharmony_ci#define B2SEL 0xC4 /* Bank 2 Select */ 268c2ecf20Sopenharmony_ci#define B3SEL 0xC6 /* Bank 3 Select */ 278c2ecf20Sopenharmony_ci#define SETETHRST 0xCA /* System Reset */ 288c2ecf20Sopenharmony_ci#define FCDISABLE 0xE0 /* Flow Control Disable */ 298c2ecf20Sopenharmony_ci#define FCSINGLE 0xE2 /* Flow Control Single */ 308c2ecf20Sopenharmony_ci#define FCMULTIPLE 0xE4 /* Flow Control Multiple */ 318c2ecf20Sopenharmony_ci#define FCCLEAR 0xE6 /* Flow Control Clear */ 328c2ecf20Sopenharmony_ci#define SETPKTDEC 0xCC /* Decrement Packet Counter */ 338c2ecf20Sopenharmony_ci#define DMASTOP 0xD2 /* DMA Stop */ 348c2ecf20Sopenharmony_ci#define DMACKSUM 0xD8 /* DMA Start Checksum */ 358c2ecf20Sopenharmony_ci#define DMACKSUMS 0xDA /* DMA Start Checksum with Seed */ 368c2ecf20Sopenharmony_ci#define DMACOPY 0xDC /* DMA Start Copy */ 378c2ecf20Sopenharmony_ci#define DMACOPYS 0xDE /* DMA Start Copy and Checksum with Seed */ 388c2ecf20Sopenharmony_ci#define SETTXRTS 0xD4 /* Request Packet Transmission */ 398c2ecf20Sopenharmony_ci#define ENABLERX 0xE8 /* Enable RX */ 408c2ecf20Sopenharmony_ci#define DISABLERX 0xEA /* Disable RX */ 418c2ecf20Sopenharmony_ci#define SETEIE 0xEC /* Enable Interrupts */ 428c2ecf20Sopenharmony_ci#define CLREIE 0xEE /* Disable Interrupts */ 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* Two byte instructions */ 458c2ecf20Sopenharmony_ci#define RBSEL 0xC8 /* Read Bank Select */ 468c2ecf20Sopenharmony_ci 478c2ecf20Sopenharmony_ci/* Three byte instructions */ 488c2ecf20Sopenharmony_ci#define WGPRDPT 0x60 /* Write EGPRDPT */ 498c2ecf20Sopenharmony_ci#define RGPRDPT 0x62 /* Read EGPRDPT */ 508c2ecf20Sopenharmony_ci#define WRXRDPT 0x64 /* Write ERXRDPT */ 518c2ecf20Sopenharmony_ci#define RRXRDPT 0x66 /* Read ERXRDPT */ 528c2ecf20Sopenharmony_ci#define WUDARDPT 0x68 /* Write EUDARDPT */ 538c2ecf20Sopenharmony_ci#define RUDARDPT 0x6A /* Read EUDARDPT */ 548c2ecf20Sopenharmony_ci#define WGPWRPT 0x6C /* Write EGPWRPT */ 558c2ecf20Sopenharmony_ci#define RGPWRPT 0x6E /* Read EGPWRPT */ 568c2ecf20Sopenharmony_ci#define WRXWRPT 0x70 /* Write ERXWRPT */ 578c2ecf20Sopenharmony_ci#define RRXWRPT 0x72 /* Read ERXWRPT */ 588c2ecf20Sopenharmony_ci#define WUDAWRPT 0x74 /* Write EUDAWRPT */ 598c2ecf20Sopenharmony_ci#define RUDAWRPT 0x76 /* Read EUDAWRPT */ 608c2ecf20Sopenharmony_ci 618c2ecf20Sopenharmony_ci/* n byte instructions */ 628c2ecf20Sopenharmony_ci#define RCRCODE 0x00 638c2ecf20Sopenharmony_ci#define WCRCODE 0x40 648c2ecf20Sopenharmony_ci#define BFSCODE 0x80 658c2ecf20Sopenharmony_ci#define BFCCODE 0xA0 668c2ecf20Sopenharmony_ci#define RCR(addr) (RCRCODE | (addr & ADDR_MASK)) /* Read Control Register */ 678c2ecf20Sopenharmony_ci#define WCR(addr) (WCRCODE | (addr & ADDR_MASK)) /* Write Control Register */ 688c2ecf20Sopenharmony_ci#define RCRU 0x20 /* Read Control Register Unbanked */ 698c2ecf20Sopenharmony_ci#define WCRU 0x22 /* Write Control Register Unbanked */ 708c2ecf20Sopenharmony_ci#define BFS(addr) (BFSCODE | (addr & ADDR_MASK)) /* Bit Field Set */ 718c2ecf20Sopenharmony_ci#define BFC(addr) (BFCCODE | (addr & ADDR_MASK)) /* Bit Field Clear */ 728c2ecf20Sopenharmony_ci#define BFSU 0x24 /* Bit Field Set Unbanked */ 738c2ecf20Sopenharmony_ci#define BFCU 0x26 /* Bit Field Clear Unbanked */ 748c2ecf20Sopenharmony_ci#define RGPDATA 0x28 /* Read EGPDATA */ 758c2ecf20Sopenharmony_ci#define WGPDATA 0x2A /* Write EGPDATA */ 768c2ecf20Sopenharmony_ci#define RRXDATA 0x2C /* Read ERXDATA */ 778c2ecf20Sopenharmony_ci#define WRXDATA 0x2E /* Write ERXDATA */ 788c2ecf20Sopenharmony_ci#define RUDADATA 0x30 /* Read EUDADATA */ 798c2ecf20Sopenharmony_ci#define WUDADATA 0x32 /* Write EUDADATA */ 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci#define SFR_REG_COUNT 0xA0 828c2ecf20Sopenharmony_ci 838c2ecf20Sopenharmony_ci/* ENC424J600 Control Registers 848c2ecf20Sopenharmony_ci * Control register definitions are a combination of address 858c2ecf20Sopenharmony_ci * and bank number 868c2ecf20Sopenharmony_ci * - Register address (bits 0-4) 878c2ecf20Sopenharmony_ci * - Bank number (bits 5-6) 888c2ecf20Sopenharmony_ci */ 898c2ecf20Sopenharmony_ci#define ADDR_MASK 0x1F 908c2ecf20Sopenharmony_ci#define BANK_MASK 0x60 918c2ecf20Sopenharmony_ci#define BANK_SHIFT 5 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/* All-bank registers */ 948c2ecf20Sopenharmony_ci#define EUDAST 0x16 958c2ecf20Sopenharmony_ci#define EUDAND 0x18 968c2ecf20Sopenharmony_ci#define ESTAT 0x1A 978c2ecf20Sopenharmony_ci#define EIR 0x1C 988c2ecf20Sopenharmony_ci#define ECON1 0x1E 998c2ecf20Sopenharmony_ci 1008c2ecf20Sopenharmony_ci/* Bank 0 registers */ 1018c2ecf20Sopenharmony_ci#define ETXST (0x00 | 0x00) 1028c2ecf20Sopenharmony_ci#define ETXLEN (0x02 | 0x00) 1038c2ecf20Sopenharmony_ci#define ERXST (0x04 | 0x00) 1048c2ecf20Sopenharmony_ci#define ERXTAIL (0x06 | 0x00) 1058c2ecf20Sopenharmony_ci#define ERXHEAD (0x08 | 0x00) 1068c2ecf20Sopenharmony_ci#define EDMAST (0x0A | 0x00) 1078c2ecf20Sopenharmony_ci#define EDMALEN (0x0C | 0x00) 1088c2ecf20Sopenharmony_ci#define EDMADST (0x0E | 0x00) 1098c2ecf20Sopenharmony_ci#define EDMACS (0x10 | 0x00) 1108c2ecf20Sopenharmony_ci#define ETXSTAT (0x12 | 0x00) 1118c2ecf20Sopenharmony_ci#define ETXWIRE (0x14 | 0x00) 1128c2ecf20Sopenharmony_ci 1138c2ecf20Sopenharmony_ci/* Bank 1 registers */ 1148c2ecf20Sopenharmony_ci#define EHT1 (0x00 | 0x20) 1158c2ecf20Sopenharmony_ci#define EHT2 (0x02 | 0x20) 1168c2ecf20Sopenharmony_ci#define EHT3 (0x04 | 0x20) 1178c2ecf20Sopenharmony_ci#define EHT4 (0x06 | 0x20) 1188c2ecf20Sopenharmony_ci#define EPMM1 (0x08 | 0x20) 1198c2ecf20Sopenharmony_ci#define EPMM2 (0x0A | 0x20) 1208c2ecf20Sopenharmony_ci#define EPMM3 (0x0C | 0x20) 1218c2ecf20Sopenharmony_ci#define EPMM4 (0x0E | 0x20) 1228c2ecf20Sopenharmony_ci#define EPMCS (0x10 | 0x20) 1238c2ecf20Sopenharmony_ci#define EPMO (0x12 | 0x20) 1248c2ecf20Sopenharmony_ci#define ERXFCON (0x14 | 0x20) 1258c2ecf20Sopenharmony_ci 1268c2ecf20Sopenharmony_ci/* Bank 2 registers */ 1278c2ecf20Sopenharmony_ci#define MACON1 (0x00 | 0x40) 1288c2ecf20Sopenharmony_ci#define MACON2 (0x02 | 0x40) 1298c2ecf20Sopenharmony_ci#define MABBIPG (0x04 | 0x40) 1308c2ecf20Sopenharmony_ci#define MAIPG (0x06 | 0x40) 1318c2ecf20Sopenharmony_ci#define MACLCON (0x08 | 0x40) 1328c2ecf20Sopenharmony_ci#define MAMXFL (0x0A | 0x40) 1338c2ecf20Sopenharmony_ci#define MICMD (0x12 | 0x40) 1348c2ecf20Sopenharmony_ci#define MIREGADR (0x14 | 0x40) 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_ci/* Bank 3 registers */ 1378c2ecf20Sopenharmony_ci#define MAADR3 (0x00 | 0x60) 1388c2ecf20Sopenharmony_ci#define MAADR2 (0x02 | 0x60) 1398c2ecf20Sopenharmony_ci#define MAADR1 (0x04 | 0x60) 1408c2ecf20Sopenharmony_ci#define MIWR (0x06 | 0x60) 1418c2ecf20Sopenharmony_ci#define MIRD (0x08 | 0x60) 1428c2ecf20Sopenharmony_ci#define MISTAT (0x0A | 0x60) 1438c2ecf20Sopenharmony_ci#define EPAUS (0x0C | 0x60) 1448c2ecf20Sopenharmony_ci#define ECON2 (0x0E | 0x60) 1458c2ecf20Sopenharmony_ci#define ERXWM (0x10 | 0x60) 1468c2ecf20Sopenharmony_ci#define EIE (0x12 | 0x60) 1478c2ecf20Sopenharmony_ci#define EIDLED (0x14 | 0x60) 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci/* Unbanked registers */ 1508c2ecf20Sopenharmony_ci#define EGPDATA (0x00 | 0x80) 1518c2ecf20Sopenharmony_ci#define ERXDATA (0x02 | 0x80) 1528c2ecf20Sopenharmony_ci#define EUDADATA (0x04 | 0x80) 1538c2ecf20Sopenharmony_ci#define EGPRDPT (0x06 | 0x80) 1548c2ecf20Sopenharmony_ci#define EGPWRPT (0x08 | 0x80) 1558c2ecf20Sopenharmony_ci#define ERXRDPT (0x0A | 0x80) 1568c2ecf20Sopenharmony_ci#define ERXWRPT (0x0C | 0x80) 1578c2ecf20Sopenharmony_ci#define EUDARDPT (0x0E | 0x80) 1588c2ecf20Sopenharmony_ci#define EUDAWRPT (0x10 | 0x80) 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci 1618c2ecf20Sopenharmony_ci/* Register bit definitions */ 1628c2ecf20Sopenharmony_ci/* ESTAT */ 1638c2ecf20Sopenharmony_ci#define INT (1 << 15) 1648c2ecf20Sopenharmony_ci#define FCIDLE (1 << 14) 1658c2ecf20Sopenharmony_ci#define RXBUSY (1 << 13) 1668c2ecf20Sopenharmony_ci#define CLKRDY (1 << 12) 1678c2ecf20Sopenharmony_ci#define PHYDPX (1 << 10) 1688c2ecf20Sopenharmony_ci#define PHYLNK (1 << 8) 1698c2ecf20Sopenharmony_ci 1708c2ecf20Sopenharmony_ci/* EIR */ 1718c2ecf20Sopenharmony_ci#define CRYPTEN (1 << 15) 1728c2ecf20Sopenharmony_ci#define MODEXIF (1 << 14) 1738c2ecf20Sopenharmony_ci#define HASHIF (1 << 13) 1748c2ecf20Sopenharmony_ci#define AESIF (1 << 12) 1758c2ecf20Sopenharmony_ci#define LINKIF (1 << 11) 1768c2ecf20Sopenharmony_ci#define PKTIF (1 << 6) 1778c2ecf20Sopenharmony_ci#define DMAIF (1 << 5) 1788c2ecf20Sopenharmony_ci#define TXIF (1 << 3) 1798c2ecf20Sopenharmony_ci#define TXABTIF (1 << 2) 1808c2ecf20Sopenharmony_ci#define RXABTIF (1 << 1) 1818c2ecf20Sopenharmony_ci#define PCFULIF (1 << 0) 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ci/* ECON1 */ 1848c2ecf20Sopenharmony_ci#define MODEXST (1 << 15) 1858c2ecf20Sopenharmony_ci#define HASHEN (1 << 14) 1868c2ecf20Sopenharmony_ci#define HASHOP (1 << 13) 1878c2ecf20Sopenharmony_ci#define HASHLST (1 << 12) 1888c2ecf20Sopenharmony_ci#define AESST (1 << 11) 1898c2ecf20Sopenharmony_ci#define AESOP1 (1 << 10) 1908c2ecf20Sopenharmony_ci#define AESOP0 (1 << 9) 1918c2ecf20Sopenharmony_ci#define PKTDEC (1 << 8) 1928c2ecf20Sopenharmony_ci#define FCOP1 (1 << 7) 1938c2ecf20Sopenharmony_ci#define FCOP0 (1 << 6) 1948c2ecf20Sopenharmony_ci#define DMAST (1 << 5) 1958c2ecf20Sopenharmony_ci#define DMACPY (1 << 4) 1968c2ecf20Sopenharmony_ci#define DMACSSD (1 << 3) 1978c2ecf20Sopenharmony_ci#define DMANOCS (1 << 2) 1988c2ecf20Sopenharmony_ci#define TXRTS (1 << 1) 1998c2ecf20Sopenharmony_ci#define RXEN (1 << 0) 2008c2ecf20Sopenharmony_ci 2018c2ecf20Sopenharmony_ci/* ETXSTAT */ 2028c2ecf20Sopenharmony_ci#define LATECOL (1 << 10) 2038c2ecf20Sopenharmony_ci#define MAXCOL (1 << 9) 2048c2ecf20Sopenharmony_ci#define EXDEFER (1 << 8) 2058c2ecf20Sopenharmony_ci#define ETXSTATL_DEFER (1 << 7) 2068c2ecf20Sopenharmony_ci#define CRCBAD (1 << 4) 2078c2ecf20Sopenharmony_ci#define COLCNT_MASK 0xF 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci/* ERXFCON */ 2108c2ecf20Sopenharmony_ci#define HTEN (1 << 15) 2118c2ecf20Sopenharmony_ci#define MPEN (1 << 14) 2128c2ecf20Sopenharmony_ci#define NOTPM (1 << 12) 2138c2ecf20Sopenharmony_ci#define PMEN3 (1 << 11) 2148c2ecf20Sopenharmony_ci#define PMEN2 (1 << 10) 2158c2ecf20Sopenharmony_ci#define PMEN1 (1 << 9) 2168c2ecf20Sopenharmony_ci#define PMEN0 (1 << 8) 2178c2ecf20Sopenharmony_ci#define CRCEEN (1 << 7) 2188c2ecf20Sopenharmony_ci#define CRCEN (1 << 6) 2198c2ecf20Sopenharmony_ci#define RUNTEEN (1 << 5) 2208c2ecf20Sopenharmony_ci#define RUNTEN (1 << 4) 2218c2ecf20Sopenharmony_ci#define UCEN (1 << 3) 2228c2ecf20Sopenharmony_ci#define NOTMEEN (1 << 2) 2238c2ecf20Sopenharmony_ci#define MCEN (1 << 1) 2248c2ecf20Sopenharmony_ci#define BCEN (1 << 0) 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_ci/* MACON1 */ 2278c2ecf20Sopenharmony_ci#define LOOPBK (1 << 4) 2288c2ecf20Sopenharmony_ci#define RXPAUS (1 << 2) 2298c2ecf20Sopenharmony_ci#define PASSALL (1 << 1) 2308c2ecf20Sopenharmony_ci 2318c2ecf20Sopenharmony_ci/* MACON2 */ 2328c2ecf20Sopenharmony_ci#define MACON2_DEFER (1 << 14) 2338c2ecf20Sopenharmony_ci#define BPEN (1 << 13) 2348c2ecf20Sopenharmony_ci#define NOBKOFF (1 << 12) 2358c2ecf20Sopenharmony_ci#define PADCFG2 (1 << 7) 2368c2ecf20Sopenharmony_ci#define PADCFG1 (1 << 6) 2378c2ecf20Sopenharmony_ci#define PADCFG0 (1 << 5) 2388c2ecf20Sopenharmony_ci#define TXCRCEN (1 << 4) 2398c2ecf20Sopenharmony_ci#define PHDREN (1 << 3) 2408c2ecf20Sopenharmony_ci#define HFRMEN (1 << 2) 2418c2ecf20Sopenharmony_ci#define MACON2_RSV1 (1 << 1) 2428c2ecf20Sopenharmony_ci#define FULDPX (1 << 0) 2438c2ecf20Sopenharmony_ci 2448c2ecf20Sopenharmony_ci/* MAIPG */ 2458c2ecf20Sopenharmony_ci/* value of the high byte is given by the reserved bits, 2468c2ecf20Sopenharmony_ci * value of the low byte is recomended setting of the 2478c2ecf20Sopenharmony_ci * IPG parameter. 2488c2ecf20Sopenharmony_ci */ 2498c2ecf20Sopenharmony_ci#define MAIPGH_VAL 0x0C 2508c2ecf20Sopenharmony_ci#define MAIPGL_VAL 0x12 2518c2ecf20Sopenharmony_ci 2528c2ecf20Sopenharmony_ci/* MIREGADRH */ 2538c2ecf20Sopenharmony_ci#define MIREGADR_VAL (1 << 8) 2548c2ecf20Sopenharmony_ci 2558c2ecf20Sopenharmony_ci/* MIREGADRL */ 2568c2ecf20Sopenharmony_ci#define PHREG_MASK 0x1F 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci/* MICMD */ 2598c2ecf20Sopenharmony_ci#define MIISCAN (1 << 1) 2608c2ecf20Sopenharmony_ci#define MIIRD (1 << 0) 2618c2ecf20Sopenharmony_ci 2628c2ecf20Sopenharmony_ci/* MISTAT */ 2638c2ecf20Sopenharmony_ci#define NVALID (1 << 2) 2648c2ecf20Sopenharmony_ci#define SCAN (1 << 1) 2658c2ecf20Sopenharmony_ci#define BUSY (1 << 0) 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci/* ECON2 */ 2688c2ecf20Sopenharmony_ci#define ETHEN (1 << 15) 2698c2ecf20Sopenharmony_ci#define STRCH (1 << 14) 2708c2ecf20Sopenharmony_ci#define TXMAC (1 << 13) 2718c2ecf20Sopenharmony_ci#define SHA1MD5 (1 << 12) 2728c2ecf20Sopenharmony_ci#define COCON3 (1 << 11) 2738c2ecf20Sopenharmony_ci#define COCON2 (1 << 10) 2748c2ecf20Sopenharmony_ci#define COCON1 (1 << 9) 2758c2ecf20Sopenharmony_ci#define COCON0 (1 << 8) 2768c2ecf20Sopenharmony_ci#define AUTOFC (1 << 7) 2778c2ecf20Sopenharmony_ci#define TXRST (1 << 6) 2788c2ecf20Sopenharmony_ci#define RXRST (1 << 5) 2798c2ecf20Sopenharmony_ci#define ETHRST (1 << 4) 2808c2ecf20Sopenharmony_ci#define MODLEN1 (1 << 3) 2818c2ecf20Sopenharmony_ci#define MODLEN0 (1 << 2) 2828c2ecf20Sopenharmony_ci#define AESLEN1 (1 << 1) 2838c2ecf20Sopenharmony_ci#define AESLEN0 (1 << 0) 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci/* EIE */ 2868c2ecf20Sopenharmony_ci#define INTIE (1 << 15) 2878c2ecf20Sopenharmony_ci#define MODEXIE (1 << 14) 2888c2ecf20Sopenharmony_ci#define HASHIE (1 << 13) 2898c2ecf20Sopenharmony_ci#define AESIE (1 << 12) 2908c2ecf20Sopenharmony_ci#define LINKIE (1 << 11) 2918c2ecf20Sopenharmony_ci#define PKTIE (1 << 6) 2928c2ecf20Sopenharmony_ci#define DMAIE (1 << 5) 2938c2ecf20Sopenharmony_ci#define TXIE (1 << 3) 2948c2ecf20Sopenharmony_ci#define TXABTIE (1 << 2) 2958c2ecf20Sopenharmony_ci#define RXABTIE (1 << 1) 2968c2ecf20Sopenharmony_ci#define PCFULIE (1 << 0) 2978c2ecf20Sopenharmony_ci 2988c2ecf20Sopenharmony_ci/* EIDLED */ 2998c2ecf20Sopenharmony_ci#define LACFG3 (1 << 15) 3008c2ecf20Sopenharmony_ci#define LACFG2 (1 << 14) 3018c2ecf20Sopenharmony_ci#define LACFG1 (1 << 13) 3028c2ecf20Sopenharmony_ci#define LACFG0 (1 << 12) 3038c2ecf20Sopenharmony_ci#define LBCFG3 (1 << 11) 3048c2ecf20Sopenharmony_ci#define LBCFG2 (1 << 10) 3058c2ecf20Sopenharmony_ci#define LBCFG1 (1 << 9) 3068c2ecf20Sopenharmony_ci#define LBCFG0 (1 << 8) 3078c2ecf20Sopenharmony_ci#define DEVID_SHIFT 5 3088c2ecf20Sopenharmony_ci#define DEVID_MASK (0x7 << DEVID_SHIFT) 3098c2ecf20Sopenharmony_ci#define REVID_SHIFT 0 3108c2ecf20Sopenharmony_ci#define REVID_MASK (0x1F << REVID_SHIFT) 3118c2ecf20Sopenharmony_ci 3128c2ecf20Sopenharmony_ci/* PHY registers */ 3138c2ecf20Sopenharmony_ci#define PHCON1 0x00 3148c2ecf20Sopenharmony_ci#define PHSTAT1 0x01 3158c2ecf20Sopenharmony_ci#define PHANA 0x04 3168c2ecf20Sopenharmony_ci#define PHANLPA 0x05 3178c2ecf20Sopenharmony_ci#define PHANE 0x06 3188c2ecf20Sopenharmony_ci#define PHCON2 0x11 3198c2ecf20Sopenharmony_ci#define PHSTAT2 0x1B 3208c2ecf20Sopenharmony_ci#define PHSTAT3 0x1F 3218c2ecf20Sopenharmony_ci 3228c2ecf20Sopenharmony_ci/* PHCON1 */ 3238c2ecf20Sopenharmony_ci#define PRST (1 << 15) 3248c2ecf20Sopenharmony_ci#define PLOOPBK (1 << 14) 3258c2ecf20Sopenharmony_ci#define SPD100 (1 << 13) 3268c2ecf20Sopenharmony_ci#define ANEN (1 << 12) 3278c2ecf20Sopenharmony_ci#define PSLEEP (1 << 11) 3288c2ecf20Sopenharmony_ci#define RENEG (1 << 9) 3298c2ecf20Sopenharmony_ci#define PFULDPX (1 << 8) 3308c2ecf20Sopenharmony_ci 3318c2ecf20Sopenharmony_ci/* PHSTAT1 */ 3328c2ecf20Sopenharmony_ci#define FULL100 (1 << 14) 3338c2ecf20Sopenharmony_ci#define HALF100 (1 << 13) 3348c2ecf20Sopenharmony_ci#define FULL10 (1 << 12) 3358c2ecf20Sopenharmony_ci#define HALF10 (1 << 11) 3368c2ecf20Sopenharmony_ci#define ANDONE (1 << 5) 3378c2ecf20Sopenharmony_ci#define LRFAULT (1 << 4) 3388c2ecf20Sopenharmony_ci#define ANABLE (1 << 3) 3398c2ecf20Sopenharmony_ci#define LLSTAT (1 << 2) 3408c2ecf20Sopenharmony_ci#define EXTREGS (1 << 0) 3418c2ecf20Sopenharmony_ci 3428c2ecf20Sopenharmony_ci/* PHSTAT2 */ 3438c2ecf20Sopenharmony_ci#define PLRITY (1 << 4) 3448c2ecf20Sopenharmony_ci 3458c2ecf20Sopenharmony_ci/* PHSTAT3 */ 3468c2ecf20Sopenharmony_ci#define PHY3SPD100 (1 << 3) 3478c2ecf20Sopenharmony_ci#define PHY3DPX (1 << 4) 3488c2ecf20Sopenharmony_ci#define SPDDPX_SHIFT 2 3498c2ecf20Sopenharmony_ci#define SPDDPX_MASK (0x7 << SPDDPX_SHIFT) 3508c2ecf20Sopenharmony_ci 3518c2ecf20Sopenharmony_ci/* PHANA */ 3528c2ecf20Sopenharmony_ci/* Default value for PHY initialization*/ 3538c2ecf20Sopenharmony_ci#define PHANA_DEFAULT 0x05E1 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_ci/* PHANE */ 3568c2ecf20Sopenharmony_ci#define PDFLT (1 << 4) 3578c2ecf20Sopenharmony_ci#define LPARCD (1 << 1) 3588c2ecf20Sopenharmony_ci#define LPANABL (1 << 0) 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci#define EUDAST_TEST_VAL 0x1234 3618c2ecf20Sopenharmony_ci 3628c2ecf20Sopenharmony_ci#define TSV_SIZE 7 3638c2ecf20Sopenharmony_ci 3648c2ecf20Sopenharmony_ci#define ENCX24J600_DEV_ID 0x1 3658c2ecf20Sopenharmony_ci 3668c2ecf20Sopenharmony_ci/* Configuration */ 3678c2ecf20Sopenharmony_ci 3688c2ecf20Sopenharmony_ci/* Led is on when the link is present and driven low 3698c2ecf20Sopenharmony_ci * temporarily when packet is TX'd or RX'd 3708c2ecf20Sopenharmony_ci */ 3718c2ecf20Sopenharmony_ci#define LED_A_SETTINGS 0xC 3728c2ecf20Sopenharmony_ci 3738c2ecf20Sopenharmony_ci/* Led is on if the link is in 100 Mbps mode */ 3748c2ecf20Sopenharmony_ci#define LED_B_SETTINGS 0x8 3758c2ecf20Sopenharmony_ci 3768c2ecf20Sopenharmony_ci/* maximum ethernet frame length 3778c2ecf20Sopenharmony_ci * Currently not used as a limit anywhere 3788c2ecf20Sopenharmony_ci * (we're using the "huge frame enable" feature of 3798c2ecf20Sopenharmony_ci * enc424j600). 3808c2ecf20Sopenharmony_ci */ 3818c2ecf20Sopenharmony_ci#define MAX_FRAMELEN 1518 3828c2ecf20Sopenharmony_ci 3838c2ecf20Sopenharmony_ci/* Size in bytes of the receive buffer in enc424j600. 3848c2ecf20Sopenharmony_ci * Must be word aligned (even). 3858c2ecf20Sopenharmony_ci */ 3868c2ecf20Sopenharmony_ci#define RX_BUFFER_SIZE (15 * MAX_FRAMELEN) 3878c2ecf20Sopenharmony_ci 3888c2ecf20Sopenharmony_ci/* Start of the general purpose area in sram */ 3898c2ecf20Sopenharmony_ci#define SRAM_GP_START 0x0 3908c2ecf20Sopenharmony_ci 3918c2ecf20Sopenharmony_ci/* SRAM size */ 3928c2ecf20Sopenharmony_ci#define SRAM_SIZE 0x6000 3938c2ecf20Sopenharmony_ci 3948c2ecf20Sopenharmony_ci/* Start of the receive buffer */ 3958c2ecf20Sopenharmony_ci#define ERXST_VAL (SRAM_SIZE - RX_BUFFER_SIZE) 3968c2ecf20Sopenharmony_ci 3978c2ecf20Sopenharmony_ci#define RSV_RXLONGEVDROPEV 16 3988c2ecf20Sopenharmony_ci#define RSV_CARRIEREV 18 3998c2ecf20Sopenharmony_ci#define RSV_CRCERROR 20 4008c2ecf20Sopenharmony_ci#define RSV_LENCHECKERR 21 4018c2ecf20Sopenharmony_ci#define RSV_LENOUTOFRANGE 22 4028c2ecf20Sopenharmony_ci#define RSV_RXOK 23 4038c2ecf20Sopenharmony_ci#define RSV_RXMULTICAST 24 4048c2ecf20Sopenharmony_ci#define RSV_RXBROADCAST 25 4058c2ecf20Sopenharmony_ci#define RSV_DRIBBLENIBBLE 26 4068c2ecf20Sopenharmony_ci#define RSV_RXCONTROLFRAME 27 4078c2ecf20Sopenharmony_ci#define RSV_RXPAUSEFRAME 28 4088c2ecf20Sopenharmony_ci#define RSV_RXUNKNOWNOPCODE 29 4098c2ecf20Sopenharmony_ci#define RSV_RXTYPEVLAN 30 4108c2ecf20Sopenharmony_ci 4118c2ecf20Sopenharmony_ci#define RSV_RUNTFILTERMATCH 31 4128c2ecf20Sopenharmony_ci#define RSV_NOTMEFILTERMATCH 32 4138c2ecf20Sopenharmony_ci#define RSV_HASHFILTERMATCH 33 4148c2ecf20Sopenharmony_ci#define RSV_MAGICPKTFILTERMATCH 34 4158c2ecf20Sopenharmony_ci#define RSV_PTRNMTCHFILTERMATCH 35 4168c2ecf20Sopenharmony_ci#define RSV_UNICASTFILTERMATCH 36 4178c2ecf20Sopenharmony_ci 4188c2ecf20Sopenharmony_ci#define RSV_SIZE 8 4198c2ecf20Sopenharmony_ci#define RSV_BITMASK(x) (1 << ((x) - 16)) 4208c2ecf20Sopenharmony_ci#define RSV_GETBIT(x, y) (((x) & RSV_BITMASK(y)) ? 1 : 0) 4218c2ecf20Sopenharmony_ci 4228c2ecf20Sopenharmony_cistruct rsv { 4238c2ecf20Sopenharmony_ci u16 next_packet; 4248c2ecf20Sopenharmony_ci u16 len; 4258c2ecf20Sopenharmony_ci u32 rxstat; 4268c2ecf20Sopenharmony_ci}; 4278c2ecf20Sopenharmony_ci 4288c2ecf20Sopenharmony_ci/* Put RX buffer at 0 as suggested by the Errata datasheet */ 4298c2ecf20Sopenharmony_ci 4308c2ecf20Sopenharmony_ci#define RXSTART_INIT ERXST_VAL 4318c2ecf20Sopenharmony_ci#define RXEND_INIT 0x5FFF 4328c2ecf20Sopenharmony_ci 4338c2ecf20Sopenharmony_ciint regmap_encx24j600_spi_write(void *context, u8 reg, const u8 *data, 4348c2ecf20Sopenharmony_ci size_t count); 4358c2ecf20Sopenharmony_ciint regmap_encx24j600_spi_read(void *context, u8 reg, u8 *data, size_t count); 4368c2ecf20Sopenharmony_ci 4378c2ecf20Sopenharmony_ci 4388c2ecf20Sopenharmony_ci#endif 439