18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * JMicron JMC2x0 series PCIe Ethernet Linux Device Driver 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright 2008 JMicron Technology Corporation 68c2ecf20Sopenharmony_ci * https://www.jmicron.com/ 78c2ecf20Sopenharmony_ci * Copyright (c) 2009 - 2010 Guo-Fu Tseng <cooldavid@cooldavid.org> 88c2ecf20Sopenharmony_ci * 98c2ecf20Sopenharmony_ci * Author: Guo-Fu Tseng <cooldavid@cooldavid.org> 108c2ecf20Sopenharmony_ci */ 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#ifndef __JME_H_INCLUDED__ 138c2ecf20Sopenharmony_ci#define __JME_H_INCLUDED__ 148c2ecf20Sopenharmony_ci#include <linux/interrupt.h> 158c2ecf20Sopenharmony_ci 168c2ecf20Sopenharmony_ci#define DRV_NAME "jme" 178c2ecf20Sopenharmony_ci#define DRV_VERSION "1.0.8" 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_JMICRON_JMC250 0x0250 208c2ecf20Sopenharmony_ci#define PCI_DEVICE_ID_JMICRON_JMC260 0x0260 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ci/* 238c2ecf20Sopenharmony_ci * Message related definitions 248c2ecf20Sopenharmony_ci */ 258c2ecf20Sopenharmony_ci#define JME_DEF_MSG_ENABLE \ 268c2ecf20Sopenharmony_ci (NETIF_MSG_PROBE | \ 278c2ecf20Sopenharmony_ci NETIF_MSG_LINK | \ 288c2ecf20Sopenharmony_ci NETIF_MSG_RX_ERR | \ 298c2ecf20Sopenharmony_ci NETIF_MSG_TX_ERR | \ 308c2ecf20Sopenharmony_ci NETIF_MSG_HW) 318c2ecf20Sopenharmony_ci 328c2ecf20Sopenharmony_ci#ifdef TX_DEBUG 338c2ecf20Sopenharmony_ci#define tx_dbg(priv, fmt, args...) \ 348c2ecf20Sopenharmony_ci printk(KERN_DEBUG "%s: " fmt, (priv)->dev->name, ##args) 358c2ecf20Sopenharmony_ci#else 368c2ecf20Sopenharmony_ci#define tx_dbg(priv, fmt, args...) \ 378c2ecf20Sopenharmony_cido { \ 388c2ecf20Sopenharmony_ci if (0) \ 398c2ecf20Sopenharmony_ci printk(KERN_DEBUG "%s: " fmt, (priv)->dev->name, ##args); \ 408c2ecf20Sopenharmony_ci} while (0) 418c2ecf20Sopenharmony_ci#endif 428c2ecf20Sopenharmony_ci 438c2ecf20Sopenharmony_ci/* 448c2ecf20Sopenharmony_ci * Extra PCI Configuration space interface 458c2ecf20Sopenharmony_ci */ 468c2ecf20Sopenharmony_ci#define PCI_DCSR_MRRS 0x59 478c2ecf20Sopenharmony_ci#define PCI_DCSR_MRRS_MASK 0x70 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_cienum pci_dcsr_mrrs_vals { 508c2ecf20Sopenharmony_ci MRRS_128B = 0x00, 518c2ecf20Sopenharmony_ci MRRS_256B = 0x10, 528c2ecf20Sopenharmony_ci MRRS_512B = 0x20, 538c2ecf20Sopenharmony_ci MRRS_1024B = 0x30, 548c2ecf20Sopenharmony_ci MRRS_2048B = 0x40, 558c2ecf20Sopenharmony_ci MRRS_4096B = 0x50, 568c2ecf20Sopenharmony_ci}; 578c2ecf20Sopenharmony_ci 588c2ecf20Sopenharmony_ci#define PCI_SPI 0xB0 598c2ecf20Sopenharmony_ci 608c2ecf20Sopenharmony_cienum pci_spi_bits { 618c2ecf20Sopenharmony_ci SPI_EN = 0x10, 628c2ecf20Sopenharmony_ci SPI_MISO = 0x08, 638c2ecf20Sopenharmony_ci SPI_MOSI = 0x04, 648c2ecf20Sopenharmony_ci SPI_SCLK = 0x02, 658c2ecf20Sopenharmony_ci SPI_CS = 0x01, 668c2ecf20Sopenharmony_ci}; 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_cistruct jme_spi_op { 698c2ecf20Sopenharmony_ci void __user *uwbuf; 708c2ecf20Sopenharmony_ci void __user *urbuf; 718c2ecf20Sopenharmony_ci __u8 wn; /* Number of write actions */ 728c2ecf20Sopenharmony_ci __u8 rn; /* Number of read actions */ 738c2ecf20Sopenharmony_ci __u8 bitn; /* Number of bits per action */ 748c2ecf20Sopenharmony_ci __u8 spd; /* The maxim acceptable speed of controller, in MHz.*/ 758c2ecf20Sopenharmony_ci __u8 mode; /* CPOL, CPHA, and Duplex mode of SPI */ 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci /* Internal use only */ 788c2ecf20Sopenharmony_ci u8 *kwbuf; 798c2ecf20Sopenharmony_ci u8 *krbuf; 808c2ecf20Sopenharmony_ci u8 sr; 818c2ecf20Sopenharmony_ci u16 halfclk; /* Half of clock cycle calculated from spd, in ns */ 828c2ecf20Sopenharmony_ci}; 838c2ecf20Sopenharmony_ci 848c2ecf20Sopenharmony_cienum jme_spi_op_bits { 858c2ecf20Sopenharmony_ci SPI_MODE_CPHA = 0x01, 868c2ecf20Sopenharmony_ci SPI_MODE_CPOL = 0x02, 878c2ecf20Sopenharmony_ci SPI_MODE_DUP = 0x80, 888c2ecf20Sopenharmony_ci}; 898c2ecf20Sopenharmony_ci 908c2ecf20Sopenharmony_ci#define HALF_US 500 /* 500 ns */ 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#define PCI_PRIV_PE1 0xE4 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cienum pci_priv_pe1_bit_masks { 958c2ecf20Sopenharmony_ci PE1_ASPMSUPRT = 0x00000003, /* 968c2ecf20Sopenharmony_ci * RW: 978c2ecf20Sopenharmony_ci * Aspm_support[1:0] 988c2ecf20Sopenharmony_ci * (R/W Port of 5C[11:10]) 998c2ecf20Sopenharmony_ci */ 1008c2ecf20Sopenharmony_ci PE1_MULTIFUN = 0x00000004, /* RW: Multi_fun_bit */ 1018c2ecf20Sopenharmony_ci PE1_RDYDMA = 0x00000008, /* RO: ~link.rdy_for_dma */ 1028c2ecf20Sopenharmony_ci PE1_ASPMOPTL = 0x00000030, /* RW: link.rx10s_option[1:0] */ 1038c2ecf20Sopenharmony_ci PE1_ASPMOPTH = 0x000000C0, /* RW: 10_req=[3]?HW:[2] */ 1048c2ecf20Sopenharmony_ci PE1_GPREG0 = 0x0000FF00, /* 1058c2ecf20Sopenharmony_ci * SRW: 1068c2ecf20Sopenharmony_ci * Cfg_gp_reg0 1078c2ecf20Sopenharmony_ci * [7:6] phy_giga BG control 1088c2ecf20Sopenharmony_ci * [5] CREQ_N as CREQ_N1 (CPPE# as CREQ#) 1098c2ecf20Sopenharmony_ci * [4:0] Reserved 1108c2ecf20Sopenharmony_ci */ 1118c2ecf20Sopenharmony_ci PE1_GPREG0_PBG = 0x0000C000, /* phy_giga BG control */ 1128c2ecf20Sopenharmony_ci PE1_GPREG1 = 0x00FF0000, /* RW: Cfg_gp_reg1 */ 1138c2ecf20Sopenharmony_ci PE1_REVID = 0xFF000000, /* RO: Rev ID */ 1148c2ecf20Sopenharmony_ci}; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_cienum pci_priv_pe1_values { 1178c2ecf20Sopenharmony_ci PE1_GPREG0_ENBG = 0x00000000, /* en BG */ 1188c2ecf20Sopenharmony_ci PE1_GPREG0_PDD3COLD = 0x00004000, /* giga_PD + d3cold */ 1198c2ecf20Sopenharmony_ci PE1_GPREG0_PDPCIESD = 0x00008000, /* giga_PD + pcie_shutdown */ 1208c2ecf20Sopenharmony_ci PE1_GPREG0_PDPCIEIDDQ = 0x0000C000, /* giga_PD + pcie_iddq */ 1218c2ecf20Sopenharmony_ci}; 1228c2ecf20Sopenharmony_ci 1238c2ecf20Sopenharmony_ci/* 1248c2ecf20Sopenharmony_ci * Dynamic(adaptive)/Static PCC values 1258c2ecf20Sopenharmony_ci */ 1268c2ecf20Sopenharmony_cienum dynamic_pcc_values { 1278c2ecf20Sopenharmony_ci PCC_OFF = 0, 1288c2ecf20Sopenharmony_ci PCC_P1 = 1, 1298c2ecf20Sopenharmony_ci PCC_P2 = 2, 1308c2ecf20Sopenharmony_ci PCC_P3 = 3, 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_ci PCC_OFF_TO = 0, 1338c2ecf20Sopenharmony_ci PCC_P1_TO = 1, 1348c2ecf20Sopenharmony_ci PCC_P2_TO = 64, 1358c2ecf20Sopenharmony_ci PCC_P3_TO = 128, 1368c2ecf20Sopenharmony_ci 1378c2ecf20Sopenharmony_ci PCC_OFF_CNT = 0, 1388c2ecf20Sopenharmony_ci PCC_P1_CNT = 1, 1398c2ecf20Sopenharmony_ci PCC_P2_CNT = 16, 1408c2ecf20Sopenharmony_ci PCC_P3_CNT = 32, 1418c2ecf20Sopenharmony_ci}; 1428c2ecf20Sopenharmony_cistruct dynpcc_info { 1438c2ecf20Sopenharmony_ci unsigned long last_bytes; 1448c2ecf20Sopenharmony_ci unsigned long last_pkts; 1458c2ecf20Sopenharmony_ci unsigned long intr_cnt; 1468c2ecf20Sopenharmony_ci unsigned char cur; 1478c2ecf20Sopenharmony_ci unsigned char attempt; 1488c2ecf20Sopenharmony_ci unsigned char cnt; 1498c2ecf20Sopenharmony_ci}; 1508c2ecf20Sopenharmony_ci#define PCC_INTERVAL_US 100000 1518c2ecf20Sopenharmony_ci#define PCC_INTERVAL (HZ / (1000000 / PCC_INTERVAL_US)) 1528c2ecf20Sopenharmony_ci#define PCC_P3_THRESHOLD (2 * 1024 * 1024) 1538c2ecf20Sopenharmony_ci#define PCC_P2_THRESHOLD 800 1548c2ecf20Sopenharmony_ci#define PCC_INTR_THRESHOLD 800 1558c2ecf20Sopenharmony_ci#define PCC_TX_TO 1000 1568c2ecf20Sopenharmony_ci#define PCC_TX_CNT 8 1578c2ecf20Sopenharmony_ci 1588c2ecf20Sopenharmony_ci/* 1598c2ecf20Sopenharmony_ci * TX/RX Descriptors 1608c2ecf20Sopenharmony_ci * 1618c2ecf20Sopenharmony_ci * TX/RX Ring DESC Count Must be multiple of 16 and <= 1024 1628c2ecf20Sopenharmony_ci */ 1638c2ecf20Sopenharmony_ci#define RING_DESC_ALIGN 16 /* Descriptor alignment */ 1648c2ecf20Sopenharmony_ci#define TX_DESC_SIZE 16 1658c2ecf20Sopenharmony_ci#define TX_RING_NR 8 1668c2ecf20Sopenharmony_ci#define TX_RING_ALLOC_SIZE(s) ((s * TX_DESC_SIZE) + RING_DESC_ALIGN) 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_cistruct txdesc { 1698c2ecf20Sopenharmony_ci union { 1708c2ecf20Sopenharmony_ci __u8 all[16]; 1718c2ecf20Sopenharmony_ci __le32 dw[4]; 1728c2ecf20Sopenharmony_ci struct { 1738c2ecf20Sopenharmony_ci /* DW0 */ 1748c2ecf20Sopenharmony_ci __le16 vlan; 1758c2ecf20Sopenharmony_ci __u8 rsv1; 1768c2ecf20Sopenharmony_ci __u8 flags; 1778c2ecf20Sopenharmony_ci 1788c2ecf20Sopenharmony_ci /* DW1 */ 1798c2ecf20Sopenharmony_ci __le16 datalen; 1808c2ecf20Sopenharmony_ci __le16 mss; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci /* DW2 */ 1838c2ecf20Sopenharmony_ci __le16 pktsize; 1848c2ecf20Sopenharmony_ci __le16 rsv2; 1858c2ecf20Sopenharmony_ci 1868c2ecf20Sopenharmony_ci /* DW3 */ 1878c2ecf20Sopenharmony_ci __le32 bufaddr; 1888c2ecf20Sopenharmony_ci } desc1; 1898c2ecf20Sopenharmony_ci struct { 1908c2ecf20Sopenharmony_ci /* DW0 */ 1918c2ecf20Sopenharmony_ci __le16 rsv1; 1928c2ecf20Sopenharmony_ci __u8 rsv2; 1938c2ecf20Sopenharmony_ci __u8 flags; 1948c2ecf20Sopenharmony_ci 1958c2ecf20Sopenharmony_ci /* DW1 */ 1968c2ecf20Sopenharmony_ci __le16 datalen; 1978c2ecf20Sopenharmony_ci __le16 rsv3; 1988c2ecf20Sopenharmony_ci 1998c2ecf20Sopenharmony_ci /* DW2 */ 2008c2ecf20Sopenharmony_ci __le32 bufaddrh; 2018c2ecf20Sopenharmony_ci 2028c2ecf20Sopenharmony_ci /* DW3 */ 2038c2ecf20Sopenharmony_ci __le32 bufaddrl; 2048c2ecf20Sopenharmony_ci } desc2; 2058c2ecf20Sopenharmony_ci struct { 2068c2ecf20Sopenharmony_ci /* DW0 */ 2078c2ecf20Sopenharmony_ci __u8 ehdrsz; 2088c2ecf20Sopenharmony_ci __u8 rsv1; 2098c2ecf20Sopenharmony_ci __u8 rsv2; 2108c2ecf20Sopenharmony_ci __u8 flags; 2118c2ecf20Sopenharmony_ci 2128c2ecf20Sopenharmony_ci /* DW1 */ 2138c2ecf20Sopenharmony_ci __le16 trycnt; 2148c2ecf20Sopenharmony_ci __le16 segcnt; 2158c2ecf20Sopenharmony_ci 2168c2ecf20Sopenharmony_ci /* DW2 */ 2178c2ecf20Sopenharmony_ci __le16 pktsz; 2188c2ecf20Sopenharmony_ci __le16 rsv3; 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci /* DW3 */ 2218c2ecf20Sopenharmony_ci __le32 bufaddrl; 2228c2ecf20Sopenharmony_ci } descwb; 2238c2ecf20Sopenharmony_ci }; 2248c2ecf20Sopenharmony_ci}; 2258c2ecf20Sopenharmony_ci 2268c2ecf20Sopenharmony_cienum jme_txdesc_flags_bits { 2278c2ecf20Sopenharmony_ci TXFLAG_OWN = 0x80, 2288c2ecf20Sopenharmony_ci TXFLAG_INT = 0x40, 2298c2ecf20Sopenharmony_ci TXFLAG_64BIT = 0x20, 2308c2ecf20Sopenharmony_ci TXFLAG_TCPCS = 0x10, 2318c2ecf20Sopenharmony_ci TXFLAG_UDPCS = 0x08, 2328c2ecf20Sopenharmony_ci TXFLAG_IPCS = 0x04, 2338c2ecf20Sopenharmony_ci TXFLAG_LSEN = 0x02, 2348c2ecf20Sopenharmony_ci TXFLAG_TAGON = 0x01, 2358c2ecf20Sopenharmony_ci}; 2368c2ecf20Sopenharmony_ci 2378c2ecf20Sopenharmony_ci#define TXDESC_MSS_SHIFT 2 2388c2ecf20Sopenharmony_cienum jme_txwbdesc_flags_bits { 2398c2ecf20Sopenharmony_ci TXWBFLAG_OWN = 0x80, 2408c2ecf20Sopenharmony_ci TXWBFLAG_INT = 0x40, 2418c2ecf20Sopenharmony_ci TXWBFLAG_TMOUT = 0x20, 2428c2ecf20Sopenharmony_ci TXWBFLAG_TRYOUT = 0x10, 2438c2ecf20Sopenharmony_ci TXWBFLAG_COL = 0x08, 2448c2ecf20Sopenharmony_ci 2458c2ecf20Sopenharmony_ci TXWBFLAG_ALLERR = TXWBFLAG_TMOUT | 2468c2ecf20Sopenharmony_ci TXWBFLAG_TRYOUT | 2478c2ecf20Sopenharmony_ci TXWBFLAG_COL, 2488c2ecf20Sopenharmony_ci}; 2498c2ecf20Sopenharmony_ci 2508c2ecf20Sopenharmony_ci#define RX_DESC_SIZE 16 2518c2ecf20Sopenharmony_ci#define RX_RING_NR 4 2528c2ecf20Sopenharmony_ci#define RX_RING_ALLOC_SIZE(s) ((s * RX_DESC_SIZE) + RING_DESC_ALIGN) 2538c2ecf20Sopenharmony_ci#define RX_BUF_DMA_ALIGN 8 2548c2ecf20Sopenharmony_ci#define RX_PREPAD_SIZE 10 2558c2ecf20Sopenharmony_ci#define ETH_CRC_LEN 2 2568c2ecf20Sopenharmony_ci#define RX_VLANHDR_LEN 2 2578c2ecf20Sopenharmony_ci#define RX_EXTRA_LEN (RX_PREPAD_SIZE + \ 2588c2ecf20Sopenharmony_ci ETH_HLEN + \ 2598c2ecf20Sopenharmony_ci ETH_CRC_LEN + \ 2608c2ecf20Sopenharmony_ci RX_VLANHDR_LEN + \ 2618c2ecf20Sopenharmony_ci RX_BUF_DMA_ALIGN) 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_cistruct rxdesc { 2648c2ecf20Sopenharmony_ci union { 2658c2ecf20Sopenharmony_ci __u8 all[16]; 2668c2ecf20Sopenharmony_ci __le32 dw[4]; 2678c2ecf20Sopenharmony_ci struct { 2688c2ecf20Sopenharmony_ci /* DW0 */ 2698c2ecf20Sopenharmony_ci __le16 rsv2; 2708c2ecf20Sopenharmony_ci __u8 rsv1; 2718c2ecf20Sopenharmony_ci __u8 flags; 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci /* DW1 */ 2748c2ecf20Sopenharmony_ci __le16 datalen; 2758c2ecf20Sopenharmony_ci __le16 wbcpl; 2768c2ecf20Sopenharmony_ci 2778c2ecf20Sopenharmony_ci /* DW2 */ 2788c2ecf20Sopenharmony_ci __le32 bufaddrh; 2798c2ecf20Sopenharmony_ci 2808c2ecf20Sopenharmony_ci /* DW3 */ 2818c2ecf20Sopenharmony_ci __le32 bufaddrl; 2828c2ecf20Sopenharmony_ci } desc1; 2838c2ecf20Sopenharmony_ci struct { 2848c2ecf20Sopenharmony_ci /* DW0 */ 2858c2ecf20Sopenharmony_ci __le16 vlan; 2868c2ecf20Sopenharmony_ci __le16 flags; 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci /* DW1 */ 2898c2ecf20Sopenharmony_ci __le16 framesize; 2908c2ecf20Sopenharmony_ci __u8 errstat; 2918c2ecf20Sopenharmony_ci __u8 desccnt; 2928c2ecf20Sopenharmony_ci 2938c2ecf20Sopenharmony_ci /* DW2 */ 2948c2ecf20Sopenharmony_ci __le32 rsshash; 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci /* DW3 */ 2978c2ecf20Sopenharmony_ci __u8 hashfun; 2988c2ecf20Sopenharmony_ci __u8 hashtype; 2998c2ecf20Sopenharmony_ci __le16 resrv; 3008c2ecf20Sopenharmony_ci } descwb; 3018c2ecf20Sopenharmony_ci }; 3028c2ecf20Sopenharmony_ci}; 3038c2ecf20Sopenharmony_ci 3048c2ecf20Sopenharmony_cienum jme_rxdesc_flags_bits { 3058c2ecf20Sopenharmony_ci RXFLAG_OWN = 0x80, 3068c2ecf20Sopenharmony_ci RXFLAG_INT = 0x40, 3078c2ecf20Sopenharmony_ci RXFLAG_64BIT = 0x20, 3088c2ecf20Sopenharmony_ci}; 3098c2ecf20Sopenharmony_ci 3108c2ecf20Sopenharmony_cienum jme_rxwbdesc_flags_bits { 3118c2ecf20Sopenharmony_ci RXWBFLAG_OWN = 0x8000, 3128c2ecf20Sopenharmony_ci RXWBFLAG_INT = 0x4000, 3138c2ecf20Sopenharmony_ci RXWBFLAG_MF = 0x2000, 3148c2ecf20Sopenharmony_ci RXWBFLAG_64BIT = 0x2000, 3158c2ecf20Sopenharmony_ci RXWBFLAG_TCPON = 0x1000, 3168c2ecf20Sopenharmony_ci RXWBFLAG_UDPON = 0x0800, 3178c2ecf20Sopenharmony_ci RXWBFLAG_IPCS = 0x0400, 3188c2ecf20Sopenharmony_ci RXWBFLAG_TCPCS = 0x0200, 3198c2ecf20Sopenharmony_ci RXWBFLAG_UDPCS = 0x0100, 3208c2ecf20Sopenharmony_ci RXWBFLAG_TAGON = 0x0080, 3218c2ecf20Sopenharmony_ci RXWBFLAG_IPV4 = 0x0040, 3228c2ecf20Sopenharmony_ci RXWBFLAG_IPV6 = 0x0020, 3238c2ecf20Sopenharmony_ci RXWBFLAG_PAUSE = 0x0010, 3248c2ecf20Sopenharmony_ci RXWBFLAG_MAGIC = 0x0008, 3258c2ecf20Sopenharmony_ci RXWBFLAG_WAKEUP = 0x0004, 3268c2ecf20Sopenharmony_ci RXWBFLAG_DEST = 0x0003, 3278c2ecf20Sopenharmony_ci RXWBFLAG_DEST_UNI = 0x0001, 3288c2ecf20Sopenharmony_ci RXWBFLAG_DEST_MUL = 0x0002, 3298c2ecf20Sopenharmony_ci RXWBFLAG_DEST_BRO = 0x0003, 3308c2ecf20Sopenharmony_ci}; 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_cienum jme_rxwbdesc_desccnt_mask { 3338c2ecf20Sopenharmony_ci RXWBDCNT_WBCPL = 0x80, 3348c2ecf20Sopenharmony_ci RXWBDCNT_DCNT = 0x7F, 3358c2ecf20Sopenharmony_ci}; 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_cienum jme_rxwbdesc_errstat_bits { 3388c2ecf20Sopenharmony_ci RXWBERR_LIMIT = 0x80, 3398c2ecf20Sopenharmony_ci RXWBERR_MIIER = 0x40, 3408c2ecf20Sopenharmony_ci RXWBERR_NIBON = 0x20, 3418c2ecf20Sopenharmony_ci RXWBERR_COLON = 0x10, 3428c2ecf20Sopenharmony_ci RXWBERR_ABORT = 0x08, 3438c2ecf20Sopenharmony_ci RXWBERR_SHORT = 0x04, 3448c2ecf20Sopenharmony_ci RXWBERR_OVERUN = 0x02, 3458c2ecf20Sopenharmony_ci RXWBERR_CRCERR = 0x01, 3468c2ecf20Sopenharmony_ci RXWBERR_ALLERR = 0xFF, 3478c2ecf20Sopenharmony_ci}; 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci/* 3508c2ecf20Sopenharmony_ci * Buffer information corresponding to ring descriptors. 3518c2ecf20Sopenharmony_ci */ 3528c2ecf20Sopenharmony_cistruct jme_buffer_info { 3538c2ecf20Sopenharmony_ci struct sk_buff *skb; 3548c2ecf20Sopenharmony_ci dma_addr_t mapping; 3558c2ecf20Sopenharmony_ci int len; 3568c2ecf20Sopenharmony_ci int nr_desc; 3578c2ecf20Sopenharmony_ci unsigned long start_xmit; 3588c2ecf20Sopenharmony_ci}; 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ci/* 3618c2ecf20Sopenharmony_ci * The structure holding buffer information and ring descriptors all together. 3628c2ecf20Sopenharmony_ci */ 3638c2ecf20Sopenharmony_cistruct jme_ring { 3648c2ecf20Sopenharmony_ci void *alloc; /* pointer to allocated memory */ 3658c2ecf20Sopenharmony_ci void *desc; /* pointer to ring memory */ 3668c2ecf20Sopenharmony_ci dma_addr_t dmaalloc; /* phys address of ring alloc */ 3678c2ecf20Sopenharmony_ci dma_addr_t dma; /* phys address for ring dma */ 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_ci /* Buffer information corresponding to each descriptor */ 3708c2ecf20Sopenharmony_ci struct jme_buffer_info *bufinf; 3718c2ecf20Sopenharmony_ci 3728c2ecf20Sopenharmony_ci int next_to_use; 3738c2ecf20Sopenharmony_ci atomic_t next_to_clean; 3748c2ecf20Sopenharmony_ci atomic_t nr_free; 3758c2ecf20Sopenharmony_ci}; 3768c2ecf20Sopenharmony_ci 3778c2ecf20Sopenharmony_ci#define NET_STAT(priv) (priv->dev->stats) 3788c2ecf20Sopenharmony_ci#define NETDEV_GET_STATS(netdev, fun_ptr) 3798c2ecf20Sopenharmony_ci#define DECLARE_NET_DEVICE_STATS 3808c2ecf20Sopenharmony_ci 3818c2ecf20Sopenharmony_ci#define DECLARE_NAPI_STRUCT struct napi_struct napi; 3828c2ecf20Sopenharmony_ci#define NETIF_NAPI_SET(dev, napis, pollfn, q) \ 3838c2ecf20Sopenharmony_ci netif_napi_add(dev, napis, pollfn, q); 3848c2ecf20Sopenharmony_ci#define JME_NAPI_HOLDER(holder) struct napi_struct *holder 3858c2ecf20Sopenharmony_ci#define JME_NAPI_WEIGHT(w) int w 3868c2ecf20Sopenharmony_ci#define JME_NAPI_WEIGHT_VAL(w) w 3878c2ecf20Sopenharmony_ci#define JME_NAPI_WEIGHT_SET(w, r) 3888c2ecf20Sopenharmony_ci#define JME_RX_COMPLETE(dev, napis) napi_complete(napis) 3898c2ecf20Sopenharmony_ci#define JME_NAPI_ENABLE(priv) napi_enable(&priv->napi); 3908c2ecf20Sopenharmony_ci#define JME_NAPI_DISABLE(priv) \ 3918c2ecf20Sopenharmony_ci if (!napi_disable_pending(&priv->napi)) \ 3928c2ecf20Sopenharmony_ci napi_disable(&priv->napi); 3938c2ecf20Sopenharmony_ci#define JME_RX_SCHEDULE_PREP(priv) \ 3948c2ecf20Sopenharmony_ci napi_schedule_prep(&priv->napi) 3958c2ecf20Sopenharmony_ci#define JME_RX_SCHEDULE(priv) \ 3968c2ecf20Sopenharmony_ci __napi_schedule(&priv->napi); 3978c2ecf20Sopenharmony_ci 3988c2ecf20Sopenharmony_ci/* 3998c2ecf20Sopenharmony_ci * Jmac Adapter Private data 4008c2ecf20Sopenharmony_ci */ 4018c2ecf20Sopenharmony_cistruct jme_adapter { 4028c2ecf20Sopenharmony_ci struct pci_dev *pdev; 4038c2ecf20Sopenharmony_ci struct net_device *dev; 4048c2ecf20Sopenharmony_ci void __iomem *regs; 4058c2ecf20Sopenharmony_ci struct mii_if_info mii_if; 4068c2ecf20Sopenharmony_ci struct jme_ring rxring[RX_RING_NR]; 4078c2ecf20Sopenharmony_ci struct jme_ring txring[TX_RING_NR]; 4088c2ecf20Sopenharmony_ci spinlock_t phy_lock; 4098c2ecf20Sopenharmony_ci spinlock_t macaddr_lock; 4108c2ecf20Sopenharmony_ci spinlock_t rxmcs_lock; 4118c2ecf20Sopenharmony_ci struct tasklet_struct rxempty_task; 4128c2ecf20Sopenharmony_ci struct tasklet_struct rxclean_task; 4138c2ecf20Sopenharmony_ci struct tasklet_struct txclean_task; 4148c2ecf20Sopenharmony_ci struct tasklet_struct linkch_task; 4158c2ecf20Sopenharmony_ci struct tasklet_struct pcc_task; 4168c2ecf20Sopenharmony_ci unsigned long flags; 4178c2ecf20Sopenharmony_ci u32 reg_txcs; 4188c2ecf20Sopenharmony_ci u32 reg_txpfc; 4198c2ecf20Sopenharmony_ci u32 reg_rxcs; 4208c2ecf20Sopenharmony_ci u32 reg_rxmcs; 4218c2ecf20Sopenharmony_ci u32 reg_ghc; 4228c2ecf20Sopenharmony_ci u32 reg_pmcs; 4238c2ecf20Sopenharmony_ci u32 reg_gpreg1; 4248c2ecf20Sopenharmony_ci u32 phylink; 4258c2ecf20Sopenharmony_ci u32 tx_ring_size; 4268c2ecf20Sopenharmony_ci u32 tx_ring_mask; 4278c2ecf20Sopenharmony_ci u32 tx_wake_threshold; 4288c2ecf20Sopenharmony_ci u32 rx_ring_size; 4298c2ecf20Sopenharmony_ci u32 rx_ring_mask; 4308c2ecf20Sopenharmony_ci u8 mrrs; 4318c2ecf20Sopenharmony_ci unsigned int fpgaver; 4328c2ecf20Sopenharmony_ci u8 chiprev; 4338c2ecf20Sopenharmony_ci u8 chip_main_rev; 4348c2ecf20Sopenharmony_ci u8 chip_sub_rev; 4358c2ecf20Sopenharmony_ci u8 pcirev; 4368c2ecf20Sopenharmony_ci u32 msg_enable; 4378c2ecf20Sopenharmony_ci struct ethtool_link_ksettings old_cmd; 4388c2ecf20Sopenharmony_ci unsigned int old_mtu; 4398c2ecf20Sopenharmony_ci struct dynpcc_info dpi; 4408c2ecf20Sopenharmony_ci atomic_t intr_sem; 4418c2ecf20Sopenharmony_ci atomic_t link_changing; 4428c2ecf20Sopenharmony_ci atomic_t tx_cleaning; 4438c2ecf20Sopenharmony_ci atomic_t rx_cleaning; 4448c2ecf20Sopenharmony_ci atomic_t rx_empty; 4458c2ecf20Sopenharmony_ci int (*jme_rx)(struct sk_buff *skb); 4468c2ecf20Sopenharmony_ci DECLARE_NAPI_STRUCT 4478c2ecf20Sopenharmony_ci DECLARE_NET_DEVICE_STATS 4488c2ecf20Sopenharmony_ci}; 4498c2ecf20Sopenharmony_ci 4508c2ecf20Sopenharmony_cienum jme_flags_bits { 4518c2ecf20Sopenharmony_ci JME_FLAG_MSI = 1, 4528c2ecf20Sopenharmony_ci JME_FLAG_SSET = 2, 4538c2ecf20Sopenharmony_ci JME_FLAG_POLL = 5, 4548c2ecf20Sopenharmony_ci JME_FLAG_SHUTDOWN = 6, 4558c2ecf20Sopenharmony_ci}; 4568c2ecf20Sopenharmony_ci 4578c2ecf20Sopenharmony_ci#define TX_TIMEOUT (5 * HZ) 4588c2ecf20Sopenharmony_ci#define JME_REG_LEN 0x500 4598c2ecf20Sopenharmony_ci#define MAX_ETHERNET_JUMBO_PACKET_SIZE 9216 4608c2ecf20Sopenharmony_ci 4618c2ecf20Sopenharmony_cistatic inline struct jme_adapter* 4628c2ecf20Sopenharmony_cijme_napi_priv(struct napi_struct *napi) 4638c2ecf20Sopenharmony_ci{ 4648c2ecf20Sopenharmony_ci struct jme_adapter *jme; 4658c2ecf20Sopenharmony_ci jme = container_of(napi, struct jme_adapter, napi); 4668c2ecf20Sopenharmony_ci return jme; 4678c2ecf20Sopenharmony_ci} 4688c2ecf20Sopenharmony_ci 4698c2ecf20Sopenharmony_ci/* 4708c2ecf20Sopenharmony_ci * MMaped I/O Resters 4718c2ecf20Sopenharmony_ci */ 4728c2ecf20Sopenharmony_cienum jme_iomap_offsets { 4738c2ecf20Sopenharmony_ci JME_MAC = 0x0000, 4748c2ecf20Sopenharmony_ci JME_PHY = 0x0400, 4758c2ecf20Sopenharmony_ci JME_MISC = 0x0800, 4768c2ecf20Sopenharmony_ci JME_RSS = 0x0C00, 4778c2ecf20Sopenharmony_ci}; 4788c2ecf20Sopenharmony_ci 4798c2ecf20Sopenharmony_cienum jme_iomap_lens { 4808c2ecf20Sopenharmony_ci JME_MAC_LEN = 0x80, 4818c2ecf20Sopenharmony_ci JME_PHY_LEN = 0x58, 4828c2ecf20Sopenharmony_ci JME_MISC_LEN = 0x98, 4838c2ecf20Sopenharmony_ci JME_RSS_LEN = 0xFF, 4848c2ecf20Sopenharmony_ci}; 4858c2ecf20Sopenharmony_ci 4868c2ecf20Sopenharmony_cienum jme_iomap_regs { 4878c2ecf20Sopenharmony_ci JME_TXCS = JME_MAC | 0x00, /* Transmit Control and Status */ 4888c2ecf20Sopenharmony_ci JME_TXDBA_LO = JME_MAC | 0x04, /* Transmit Queue Desc Base Addr */ 4898c2ecf20Sopenharmony_ci JME_TXDBA_HI = JME_MAC | 0x08, /* Transmit Queue Desc Base Addr */ 4908c2ecf20Sopenharmony_ci JME_TXQDC = JME_MAC | 0x0C, /* Transmit Queue Desc Count */ 4918c2ecf20Sopenharmony_ci JME_TXNDA = JME_MAC | 0x10, /* Transmit Queue Next Desc Addr */ 4928c2ecf20Sopenharmony_ci JME_TXMCS = JME_MAC | 0x14, /* Transmit MAC Control Status */ 4938c2ecf20Sopenharmony_ci JME_TXPFC = JME_MAC | 0x18, /* Transmit Pause Frame Control */ 4948c2ecf20Sopenharmony_ci JME_TXTRHD = JME_MAC | 0x1C, /* Transmit Timer/Retry@Half-Dup */ 4958c2ecf20Sopenharmony_ci 4968c2ecf20Sopenharmony_ci JME_RXCS = JME_MAC | 0x20, /* Receive Control and Status */ 4978c2ecf20Sopenharmony_ci JME_RXDBA_LO = JME_MAC | 0x24, /* Receive Queue Desc Base Addr */ 4988c2ecf20Sopenharmony_ci JME_RXDBA_HI = JME_MAC | 0x28, /* Receive Queue Desc Base Addr */ 4998c2ecf20Sopenharmony_ci JME_RXQDC = JME_MAC | 0x2C, /* Receive Queue Desc Count */ 5008c2ecf20Sopenharmony_ci JME_RXNDA = JME_MAC | 0x30, /* Receive Queue Next Desc Addr */ 5018c2ecf20Sopenharmony_ci JME_RXMCS = JME_MAC | 0x34, /* Receive MAC Control Status */ 5028c2ecf20Sopenharmony_ci JME_RXUMA_LO = JME_MAC | 0x38, /* Receive Unicast MAC Address */ 5038c2ecf20Sopenharmony_ci JME_RXUMA_HI = JME_MAC | 0x3C, /* Receive Unicast MAC Address */ 5048c2ecf20Sopenharmony_ci JME_RXMCHT_LO = JME_MAC | 0x40, /* Recv Multicast Addr HashTable */ 5058c2ecf20Sopenharmony_ci JME_RXMCHT_HI = JME_MAC | 0x44, /* Recv Multicast Addr HashTable */ 5068c2ecf20Sopenharmony_ci JME_WFODP = JME_MAC | 0x48, /* Wakeup Frame Output Data Port */ 5078c2ecf20Sopenharmony_ci JME_WFOI = JME_MAC | 0x4C, /* Wakeup Frame Output Interface */ 5088c2ecf20Sopenharmony_ci 5098c2ecf20Sopenharmony_ci JME_SMI = JME_MAC | 0x50, /* Station Management Interface */ 5108c2ecf20Sopenharmony_ci JME_GHC = JME_MAC | 0x54, /* Global Host Control */ 5118c2ecf20Sopenharmony_ci JME_PMCS = JME_MAC | 0x60, /* Power Management Control/Stat */ 5128c2ecf20Sopenharmony_ci 5138c2ecf20Sopenharmony_ci 5148c2ecf20Sopenharmony_ci JME_PHY_PWR = JME_PHY | 0x24, /* New PHY Power Ctrl Register */ 5158c2ecf20Sopenharmony_ci JME_PHY_CS = JME_PHY | 0x28, /* PHY Ctrl and Status Register */ 5168c2ecf20Sopenharmony_ci JME_PHY_LINK = JME_PHY | 0x30, /* PHY Link Status Register */ 5178c2ecf20Sopenharmony_ci JME_SMBCSR = JME_PHY | 0x40, /* SMB Control and Status */ 5188c2ecf20Sopenharmony_ci JME_SMBINTF = JME_PHY | 0x44, /* SMB Interface */ 5198c2ecf20Sopenharmony_ci 5208c2ecf20Sopenharmony_ci 5218c2ecf20Sopenharmony_ci JME_TMCSR = JME_MISC | 0x00, /* Timer Control/Status Register */ 5228c2ecf20Sopenharmony_ci JME_GPREG0 = JME_MISC | 0x08, /* General purpose REG-0 */ 5238c2ecf20Sopenharmony_ci JME_GPREG1 = JME_MISC | 0x0C, /* General purpose REG-1 */ 5248c2ecf20Sopenharmony_ci JME_IEVE = JME_MISC | 0x20, /* Interrupt Event Status */ 5258c2ecf20Sopenharmony_ci JME_IREQ = JME_MISC | 0x24, /* Intr Req Status(For Debug) */ 5268c2ecf20Sopenharmony_ci JME_IENS = JME_MISC | 0x28, /* Intr Enable - Setting Port */ 5278c2ecf20Sopenharmony_ci JME_IENC = JME_MISC | 0x2C, /* Interrupt Enable - Clear Port */ 5288c2ecf20Sopenharmony_ci JME_PCCRX0 = JME_MISC | 0x30, /* PCC Control for RX Queue 0 */ 5298c2ecf20Sopenharmony_ci JME_PCCTX = JME_MISC | 0x40, /* PCC Control for TX Queues */ 5308c2ecf20Sopenharmony_ci JME_CHIPMODE = JME_MISC | 0x44, /* Identify FPGA Version */ 5318c2ecf20Sopenharmony_ci JME_SHBA_HI = JME_MISC | 0x48, /* Shadow Register Base HI */ 5328c2ecf20Sopenharmony_ci JME_SHBA_LO = JME_MISC | 0x4C, /* Shadow Register Base LO */ 5338c2ecf20Sopenharmony_ci JME_TIMER1 = JME_MISC | 0x70, /* Timer1 */ 5348c2ecf20Sopenharmony_ci JME_TIMER2 = JME_MISC | 0x74, /* Timer2 */ 5358c2ecf20Sopenharmony_ci JME_APMC = JME_MISC | 0x7C, /* Aggressive Power Mode Control */ 5368c2ecf20Sopenharmony_ci JME_PCCSRX0 = JME_MISC | 0x80, /* PCC Status of RX0 */ 5378c2ecf20Sopenharmony_ci}; 5388c2ecf20Sopenharmony_ci 5398c2ecf20Sopenharmony_ci/* 5408c2ecf20Sopenharmony_ci * TX Control/Status Bits 5418c2ecf20Sopenharmony_ci */ 5428c2ecf20Sopenharmony_cienum jme_txcs_bits { 5438c2ecf20Sopenharmony_ci TXCS_QUEUE7S = 0x00008000, 5448c2ecf20Sopenharmony_ci TXCS_QUEUE6S = 0x00004000, 5458c2ecf20Sopenharmony_ci TXCS_QUEUE5S = 0x00002000, 5468c2ecf20Sopenharmony_ci TXCS_QUEUE4S = 0x00001000, 5478c2ecf20Sopenharmony_ci TXCS_QUEUE3S = 0x00000800, 5488c2ecf20Sopenharmony_ci TXCS_QUEUE2S = 0x00000400, 5498c2ecf20Sopenharmony_ci TXCS_QUEUE1S = 0x00000200, 5508c2ecf20Sopenharmony_ci TXCS_QUEUE0S = 0x00000100, 5518c2ecf20Sopenharmony_ci TXCS_FIFOTH = 0x000000C0, 5528c2ecf20Sopenharmony_ci TXCS_DMASIZE = 0x00000030, 5538c2ecf20Sopenharmony_ci TXCS_BURST = 0x00000004, 5548c2ecf20Sopenharmony_ci TXCS_ENABLE = 0x00000001, 5558c2ecf20Sopenharmony_ci}; 5568c2ecf20Sopenharmony_ci 5578c2ecf20Sopenharmony_cienum jme_txcs_value { 5588c2ecf20Sopenharmony_ci TXCS_FIFOTH_16QW = 0x000000C0, 5598c2ecf20Sopenharmony_ci TXCS_FIFOTH_12QW = 0x00000080, 5608c2ecf20Sopenharmony_ci TXCS_FIFOTH_8QW = 0x00000040, 5618c2ecf20Sopenharmony_ci TXCS_FIFOTH_4QW = 0x00000000, 5628c2ecf20Sopenharmony_ci 5638c2ecf20Sopenharmony_ci TXCS_DMASIZE_64B = 0x00000000, 5648c2ecf20Sopenharmony_ci TXCS_DMASIZE_128B = 0x00000010, 5658c2ecf20Sopenharmony_ci TXCS_DMASIZE_256B = 0x00000020, 5668c2ecf20Sopenharmony_ci TXCS_DMASIZE_512B = 0x00000030, 5678c2ecf20Sopenharmony_ci 5688c2ecf20Sopenharmony_ci TXCS_SELECT_QUEUE0 = 0x00000000, 5698c2ecf20Sopenharmony_ci TXCS_SELECT_QUEUE1 = 0x00010000, 5708c2ecf20Sopenharmony_ci TXCS_SELECT_QUEUE2 = 0x00020000, 5718c2ecf20Sopenharmony_ci TXCS_SELECT_QUEUE3 = 0x00030000, 5728c2ecf20Sopenharmony_ci TXCS_SELECT_QUEUE4 = 0x00040000, 5738c2ecf20Sopenharmony_ci TXCS_SELECT_QUEUE5 = 0x00050000, 5748c2ecf20Sopenharmony_ci TXCS_SELECT_QUEUE6 = 0x00060000, 5758c2ecf20Sopenharmony_ci TXCS_SELECT_QUEUE7 = 0x00070000, 5768c2ecf20Sopenharmony_ci 5778c2ecf20Sopenharmony_ci TXCS_DEFAULT = TXCS_FIFOTH_4QW | 5788c2ecf20Sopenharmony_ci TXCS_BURST, 5798c2ecf20Sopenharmony_ci}; 5808c2ecf20Sopenharmony_ci 5818c2ecf20Sopenharmony_ci#define JME_TX_DISABLE_TIMEOUT 10 /* 10 msec */ 5828c2ecf20Sopenharmony_ci 5838c2ecf20Sopenharmony_ci/* 5848c2ecf20Sopenharmony_ci * TX MAC Control/Status Bits 5858c2ecf20Sopenharmony_ci */ 5868c2ecf20Sopenharmony_cienum jme_txmcs_bit_masks { 5878c2ecf20Sopenharmony_ci TXMCS_IFG2 = 0xC0000000, 5888c2ecf20Sopenharmony_ci TXMCS_IFG1 = 0x30000000, 5898c2ecf20Sopenharmony_ci TXMCS_TTHOLD = 0x00000300, 5908c2ecf20Sopenharmony_ci TXMCS_FBURST = 0x00000080, 5918c2ecf20Sopenharmony_ci TXMCS_CARRIEREXT = 0x00000040, 5928c2ecf20Sopenharmony_ci TXMCS_DEFER = 0x00000020, 5938c2ecf20Sopenharmony_ci TXMCS_BACKOFF = 0x00000010, 5948c2ecf20Sopenharmony_ci TXMCS_CARRIERSENSE = 0x00000008, 5958c2ecf20Sopenharmony_ci TXMCS_COLLISION = 0x00000004, 5968c2ecf20Sopenharmony_ci TXMCS_CRC = 0x00000002, 5978c2ecf20Sopenharmony_ci TXMCS_PADDING = 0x00000001, 5988c2ecf20Sopenharmony_ci}; 5998c2ecf20Sopenharmony_ci 6008c2ecf20Sopenharmony_cienum jme_txmcs_values { 6018c2ecf20Sopenharmony_ci TXMCS_IFG2_6_4 = 0x00000000, 6028c2ecf20Sopenharmony_ci TXMCS_IFG2_8_5 = 0x40000000, 6038c2ecf20Sopenharmony_ci TXMCS_IFG2_10_6 = 0x80000000, 6048c2ecf20Sopenharmony_ci TXMCS_IFG2_12_7 = 0xC0000000, 6058c2ecf20Sopenharmony_ci 6068c2ecf20Sopenharmony_ci TXMCS_IFG1_8_4 = 0x00000000, 6078c2ecf20Sopenharmony_ci TXMCS_IFG1_12_6 = 0x10000000, 6088c2ecf20Sopenharmony_ci TXMCS_IFG1_16_8 = 0x20000000, 6098c2ecf20Sopenharmony_ci TXMCS_IFG1_20_10 = 0x30000000, 6108c2ecf20Sopenharmony_ci 6118c2ecf20Sopenharmony_ci TXMCS_TTHOLD_1_8 = 0x00000000, 6128c2ecf20Sopenharmony_ci TXMCS_TTHOLD_1_4 = 0x00000100, 6138c2ecf20Sopenharmony_ci TXMCS_TTHOLD_1_2 = 0x00000200, 6148c2ecf20Sopenharmony_ci TXMCS_TTHOLD_FULL = 0x00000300, 6158c2ecf20Sopenharmony_ci 6168c2ecf20Sopenharmony_ci TXMCS_DEFAULT = TXMCS_IFG2_8_5 | 6178c2ecf20Sopenharmony_ci TXMCS_IFG1_16_8 | 6188c2ecf20Sopenharmony_ci TXMCS_TTHOLD_FULL | 6198c2ecf20Sopenharmony_ci TXMCS_DEFER | 6208c2ecf20Sopenharmony_ci TXMCS_CRC | 6218c2ecf20Sopenharmony_ci TXMCS_PADDING, 6228c2ecf20Sopenharmony_ci}; 6238c2ecf20Sopenharmony_ci 6248c2ecf20Sopenharmony_cienum jme_txpfc_bits_masks { 6258c2ecf20Sopenharmony_ci TXPFC_VLAN_TAG = 0xFFFF0000, 6268c2ecf20Sopenharmony_ci TXPFC_VLAN_EN = 0x00008000, 6278c2ecf20Sopenharmony_ci TXPFC_PF_EN = 0x00000001, 6288c2ecf20Sopenharmony_ci}; 6298c2ecf20Sopenharmony_ci 6308c2ecf20Sopenharmony_cienum jme_txtrhd_bits_masks { 6318c2ecf20Sopenharmony_ci TXTRHD_TXPEN = 0x80000000, 6328c2ecf20Sopenharmony_ci TXTRHD_TXP = 0x7FFFFF00, 6338c2ecf20Sopenharmony_ci TXTRHD_TXREN = 0x00000080, 6348c2ecf20Sopenharmony_ci TXTRHD_TXRL = 0x0000007F, 6358c2ecf20Sopenharmony_ci}; 6368c2ecf20Sopenharmony_ci 6378c2ecf20Sopenharmony_cienum jme_txtrhd_shifts { 6388c2ecf20Sopenharmony_ci TXTRHD_TXP_SHIFT = 8, 6398c2ecf20Sopenharmony_ci TXTRHD_TXRL_SHIFT = 0, 6408c2ecf20Sopenharmony_ci}; 6418c2ecf20Sopenharmony_ci 6428c2ecf20Sopenharmony_cienum jme_txtrhd_values { 6438c2ecf20Sopenharmony_ci TXTRHD_FULLDUPLEX = 0x00000000, 6448c2ecf20Sopenharmony_ci TXTRHD_HALFDUPLEX = TXTRHD_TXPEN | 6458c2ecf20Sopenharmony_ci ((0x2000 << TXTRHD_TXP_SHIFT) & TXTRHD_TXP) | 6468c2ecf20Sopenharmony_ci TXTRHD_TXREN | 6478c2ecf20Sopenharmony_ci ((8 << TXTRHD_TXRL_SHIFT) & TXTRHD_TXRL), 6488c2ecf20Sopenharmony_ci}; 6498c2ecf20Sopenharmony_ci 6508c2ecf20Sopenharmony_ci/* 6518c2ecf20Sopenharmony_ci * RX Control/Status Bits 6528c2ecf20Sopenharmony_ci */ 6538c2ecf20Sopenharmony_cienum jme_rxcs_bit_masks { 6548c2ecf20Sopenharmony_ci /* FIFO full threshold for transmitting Tx Pause Packet */ 6558c2ecf20Sopenharmony_ci RXCS_FIFOTHTP = 0x30000000, 6568c2ecf20Sopenharmony_ci /* FIFO threshold for processing next packet */ 6578c2ecf20Sopenharmony_ci RXCS_FIFOTHNP = 0x0C000000, 6588c2ecf20Sopenharmony_ci RXCS_DMAREQSZ = 0x03000000, /* DMA Request Size */ 6598c2ecf20Sopenharmony_ci RXCS_QUEUESEL = 0x00030000, /* Queue selection */ 6608c2ecf20Sopenharmony_ci RXCS_RETRYGAP = 0x0000F000, /* RX Desc full retry gap */ 6618c2ecf20Sopenharmony_ci RXCS_RETRYCNT = 0x00000F00, /* RX Desc full retry counter */ 6628c2ecf20Sopenharmony_ci RXCS_WAKEUP = 0x00000040, /* Enable receive wakeup packet */ 6638c2ecf20Sopenharmony_ci RXCS_MAGIC = 0x00000020, /* Enable receive magic packet */ 6648c2ecf20Sopenharmony_ci RXCS_SHORT = 0x00000010, /* Enable receive short packet */ 6658c2ecf20Sopenharmony_ci RXCS_ABORT = 0x00000008, /* Enable receive errorr packet */ 6668c2ecf20Sopenharmony_ci RXCS_QST = 0x00000004, /* Receive queue start */ 6678c2ecf20Sopenharmony_ci RXCS_SUSPEND = 0x00000002, 6688c2ecf20Sopenharmony_ci RXCS_ENABLE = 0x00000001, 6698c2ecf20Sopenharmony_ci}; 6708c2ecf20Sopenharmony_ci 6718c2ecf20Sopenharmony_cienum jme_rxcs_values { 6728c2ecf20Sopenharmony_ci RXCS_FIFOTHTP_16T = 0x00000000, 6738c2ecf20Sopenharmony_ci RXCS_FIFOTHTP_32T = 0x10000000, 6748c2ecf20Sopenharmony_ci RXCS_FIFOTHTP_64T = 0x20000000, 6758c2ecf20Sopenharmony_ci RXCS_FIFOTHTP_128T = 0x30000000, 6768c2ecf20Sopenharmony_ci 6778c2ecf20Sopenharmony_ci RXCS_FIFOTHNP_16QW = 0x00000000, 6788c2ecf20Sopenharmony_ci RXCS_FIFOTHNP_32QW = 0x04000000, 6798c2ecf20Sopenharmony_ci RXCS_FIFOTHNP_64QW = 0x08000000, 6808c2ecf20Sopenharmony_ci RXCS_FIFOTHNP_128QW = 0x0C000000, 6818c2ecf20Sopenharmony_ci 6828c2ecf20Sopenharmony_ci RXCS_DMAREQSZ_16B = 0x00000000, 6838c2ecf20Sopenharmony_ci RXCS_DMAREQSZ_32B = 0x01000000, 6848c2ecf20Sopenharmony_ci RXCS_DMAREQSZ_64B = 0x02000000, 6858c2ecf20Sopenharmony_ci RXCS_DMAREQSZ_128B = 0x03000000, 6868c2ecf20Sopenharmony_ci 6878c2ecf20Sopenharmony_ci RXCS_QUEUESEL_Q0 = 0x00000000, 6888c2ecf20Sopenharmony_ci RXCS_QUEUESEL_Q1 = 0x00010000, 6898c2ecf20Sopenharmony_ci RXCS_QUEUESEL_Q2 = 0x00020000, 6908c2ecf20Sopenharmony_ci RXCS_QUEUESEL_Q3 = 0x00030000, 6918c2ecf20Sopenharmony_ci 6928c2ecf20Sopenharmony_ci RXCS_RETRYGAP_256ns = 0x00000000, 6938c2ecf20Sopenharmony_ci RXCS_RETRYGAP_512ns = 0x00001000, 6948c2ecf20Sopenharmony_ci RXCS_RETRYGAP_1024ns = 0x00002000, 6958c2ecf20Sopenharmony_ci RXCS_RETRYGAP_2048ns = 0x00003000, 6968c2ecf20Sopenharmony_ci RXCS_RETRYGAP_4096ns = 0x00004000, 6978c2ecf20Sopenharmony_ci RXCS_RETRYGAP_8192ns = 0x00005000, 6988c2ecf20Sopenharmony_ci RXCS_RETRYGAP_16384ns = 0x00006000, 6998c2ecf20Sopenharmony_ci RXCS_RETRYGAP_32768ns = 0x00007000, 7008c2ecf20Sopenharmony_ci 7018c2ecf20Sopenharmony_ci RXCS_RETRYCNT_0 = 0x00000000, 7028c2ecf20Sopenharmony_ci RXCS_RETRYCNT_4 = 0x00000100, 7038c2ecf20Sopenharmony_ci RXCS_RETRYCNT_8 = 0x00000200, 7048c2ecf20Sopenharmony_ci RXCS_RETRYCNT_12 = 0x00000300, 7058c2ecf20Sopenharmony_ci RXCS_RETRYCNT_16 = 0x00000400, 7068c2ecf20Sopenharmony_ci RXCS_RETRYCNT_20 = 0x00000500, 7078c2ecf20Sopenharmony_ci RXCS_RETRYCNT_24 = 0x00000600, 7088c2ecf20Sopenharmony_ci RXCS_RETRYCNT_28 = 0x00000700, 7098c2ecf20Sopenharmony_ci RXCS_RETRYCNT_32 = 0x00000800, 7108c2ecf20Sopenharmony_ci RXCS_RETRYCNT_36 = 0x00000900, 7118c2ecf20Sopenharmony_ci RXCS_RETRYCNT_40 = 0x00000A00, 7128c2ecf20Sopenharmony_ci RXCS_RETRYCNT_44 = 0x00000B00, 7138c2ecf20Sopenharmony_ci RXCS_RETRYCNT_48 = 0x00000C00, 7148c2ecf20Sopenharmony_ci RXCS_RETRYCNT_52 = 0x00000D00, 7158c2ecf20Sopenharmony_ci RXCS_RETRYCNT_56 = 0x00000E00, 7168c2ecf20Sopenharmony_ci RXCS_RETRYCNT_60 = 0x00000F00, 7178c2ecf20Sopenharmony_ci 7188c2ecf20Sopenharmony_ci RXCS_DEFAULT = RXCS_FIFOTHTP_128T | 7198c2ecf20Sopenharmony_ci RXCS_FIFOTHNP_16QW | 7208c2ecf20Sopenharmony_ci RXCS_DMAREQSZ_128B | 7218c2ecf20Sopenharmony_ci RXCS_RETRYGAP_256ns | 7228c2ecf20Sopenharmony_ci RXCS_RETRYCNT_32, 7238c2ecf20Sopenharmony_ci}; 7248c2ecf20Sopenharmony_ci 7258c2ecf20Sopenharmony_ci#define JME_RX_DISABLE_TIMEOUT 10 /* 10 msec */ 7268c2ecf20Sopenharmony_ci 7278c2ecf20Sopenharmony_ci/* 7288c2ecf20Sopenharmony_ci * RX MAC Control/Status Bits 7298c2ecf20Sopenharmony_ci */ 7308c2ecf20Sopenharmony_cienum jme_rxmcs_bits { 7318c2ecf20Sopenharmony_ci RXMCS_ALLFRAME = 0x00000800, 7328c2ecf20Sopenharmony_ci RXMCS_BRDFRAME = 0x00000400, 7338c2ecf20Sopenharmony_ci RXMCS_MULFRAME = 0x00000200, 7348c2ecf20Sopenharmony_ci RXMCS_UNIFRAME = 0x00000100, 7358c2ecf20Sopenharmony_ci RXMCS_ALLMULFRAME = 0x00000080, 7368c2ecf20Sopenharmony_ci RXMCS_MULFILTERED = 0x00000040, 7378c2ecf20Sopenharmony_ci RXMCS_RXCOLLDEC = 0x00000020, 7388c2ecf20Sopenharmony_ci RXMCS_FLOWCTRL = 0x00000008, 7398c2ecf20Sopenharmony_ci RXMCS_VTAGRM = 0x00000004, 7408c2ecf20Sopenharmony_ci RXMCS_PREPAD = 0x00000002, 7418c2ecf20Sopenharmony_ci RXMCS_CHECKSUM = 0x00000001, 7428c2ecf20Sopenharmony_ci 7438c2ecf20Sopenharmony_ci RXMCS_DEFAULT = RXMCS_VTAGRM | 7448c2ecf20Sopenharmony_ci RXMCS_PREPAD | 7458c2ecf20Sopenharmony_ci RXMCS_FLOWCTRL | 7468c2ecf20Sopenharmony_ci RXMCS_CHECKSUM, 7478c2ecf20Sopenharmony_ci}; 7488c2ecf20Sopenharmony_ci 7498c2ecf20Sopenharmony_ci/* Extern PHY common register 2 */ 7508c2ecf20Sopenharmony_ci 7518c2ecf20Sopenharmony_ci#define PHY_GAD_TEST_MODE_1 0x00002000 7528c2ecf20Sopenharmony_ci#define PHY_GAD_TEST_MODE_MSK 0x0000E000 7538c2ecf20Sopenharmony_ci#define JM_PHY_SPEC_REG_READ 0x00004000 7548c2ecf20Sopenharmony_ci#define JM_PHY_SPEC_REG_WRITE 0x00008000 7558c2ecf20Sopenharmony_ci#define PHY_CALIBRATION_DELAY 20 7568c2ecf20Sopenharmony_ci#define JM_PHY_SPEC_ADDR_REG 0x1E 7578c2ecf20Sopenharmony_ci#define JM_PHY_SPEC_DATA_REG 0x1F 7588c2ecf20Sopenharmony_ci 7598c2ecf20Sopenharmony_ci#define JM_PHY_EXT_COMM_0_REG 0x30 7608c2ecf20Sopenharmony_ci#define JM_PHY_EXT_COMM_1_REG 0x31 7618c2ecf20Sopenharmony_ci#define JM_PHY_EXT_COMM_2_REG 0x32 7628c2ecf20Sopenharmony_ci#define JM_PHY_EXT_COMM_2_CALI_ENABLE 0x01 7638c2ecf20Sopenharmony_ci#define JM_PHY_EXT_COMM_2_CALI_MODE_0 0x02 7648c2ecf20Sopenharmony_ci#define JM_PHY_EXT_COMM_2_CALI_LATCH 0x10 7658c2ecf20Sopenharmony_ci#define PCI_PRIV_SHARE_NICCTRL 0xF5 7668c2ecf20Sopenharmony_ci#define JME_FLAG_PHYEA_ENABLE 0x2 7678c2ecf20Sopenharmony_ci 7688c2ecf20Sopenharmony_ci/* 7698c2ecf20Sopenharmony_ci * Wakeup Frame setup interface registers 7708c2ecf20Sopenharmony_ci */ 7718c2ecf20Sopenharmony_ci#define WAKEUP_FRAME_NR 8 7728c2ecf20Sopenharmony_ci#define WAKEUP_FRAME_MASK_DWNR 4 7738c2ecf20Sopenharmony_ci 7748c2ecf20Sopenharmony_cienum jme_wfoi_bit_masks { 7758c2ecf20Sopenharmony_ci WFOI_MASK_SEL = 0x00000070, 7768c2ecf20Sopenharmony_ci WFOI_CRC_SEL = 0x00000008, 7778c2ecf20Sopenharmony_ci WFOI_FRAME_SEL = 0x00000007, 7788c2ecf20Sopenharmony_ci}; 7798c2ecf20Sopenharmony_ci 7808c2ecf20Sopenharmony_cienum jme_wfoi_shifts { 7818c2ecf20Sopenharmony_ci WFOI_MASK_SHIFT = 4, 7828c2ecf20Sopenharmony_ci}; 7838c2ecf20Sopenharmony_ci 7848c2ecf20Sopenharmony_ci/* 7858c2ecf20Sopenharmony_ci * SMI Related definitions 7868c2ecf20Sopenharmony_ci */ 7878c2ecf20Sopenharmony_cienum jme_smi_bit_mask { 7888c2ecf20Sopenharmony_ci SMI_DATA_MASK = 0xFFFF0000, 7898c2ecf20Sopenharmony_ci SMI_REG_ADDR_MASK = 0x0000F800, 7908c2ecf20Sopenharmony_ci SMI_PHY_ADDR_MASK = 0x000007C0, 7918c2ecf20Sopenharmony_ci SMI_OP_WRITE = 0x00000020, 7928c2ecf20Sopenharmony_ci /* Set to 1, after req done it'll be cleared to 0 */ 7938c2ecf20Sopenharmony_ci SMI_OP_REQ = 0x00000010, 7948c2ecf20Sopenharmony_ci SMI_OP_MDIO = 0x00000008, /* Software assess In/Out */ 7958c2ecf20Sopenharmony_ci SMI_OP_MDOE = 0x00000004, /* Software Output Enable */ 7968c2ecf20Sopenharmony_ci SMI_OP_MDC = 0x00000002, /* Software CLK Control */ 7978c2ecf20Sopenharmony_ci SMI_OP_MDEN = 0x00000001, /* Software access Enable */ 7988c2ecf20Sopenharmony_ci}; 7998c2ecf20Sopenharmony_ci 8008c2ecf20Sopenharmony_cienum jme_smi_bit_shift { 8018c2ecf20Sopenharmony_ci SMI_DATA_SHIFT = 16, 8028c2ecf20Sopenharmony_ci SMI_REG_ADDR_SHIFT = 11, 8038c2ecf20Sopenharmony_ci SMI_PHY_ADDR_SHIFT = 6, 8048c2ecf20Sopenharmony_ci}; 8058c2ecf20Sopenharmony_ci 8068c2ecf20Sopenharmony_cistatic inline u32 smi_reg_addr(int x) 8078c2ecf20Sopenharmony_ci{ 8088c2ecf20Sopenharmony_ci return (x << SMI_REG_ADDR_SHIFT) & SMI_REG_ADDR_MASK; 8098c2ecf20Sopenharmony_ci} 8108c2ecf20Sopenharmony_ci 8118c2ecf20Sopenharmony_cistatic inline u32 smi_phy_addr(int x) 8128c2ecf20Sopenharmony_ci{ 8138c2ecf20Sopenharmony_ci return (x << SMI_PHY_ADDR_SHIFT) & SMI_PHY_ADDR_MASK; 8148c2ecf20Sopenharmony_ci} 8158c2ecf20Sopenharmony_ci 8168c2ecf20Sopenharmony_ci#define JME_PHY_TIMEOUT 100 /* 100 msec */ 8178c2ecf20Sopenharmony_ci#define JME_PHY_REG_NR 32 8188c2ecf20Sopenharmony_ci 8198c2ecf20Sopenharmony_ci/* 8208c2ecf20Sopenharmony_ci * Global Host Control 8218c2ecf20Sopenharmony_ci */ 8228c2ecf20Sopenharmony_cienum jme_ghc_bit_mask { 8238c2ecf20Sopenharmony_ci GHC_SWRST = 0x40000000, 8248c2ecf20Sopenharmony_ci GHC_TO_CLK_SRC = 0x00C00000, 8258c2ecf20Sopenharmony_ci GHC_TXMAC_CLK_SRC = 0x00300000, 8268c2ecf20Sopenharmony_ci GHC_DPX = 0x00000040, 8278c2ecf20Sopenharmony_ci GHC_SPEED = 0x00000030, 8288c2ecf20Sopenharmony_ci GHC_LINK_POLL = 0x00000001, 8298c2ecf20Sopenharmony_ci}; 8308c2ecf20Sopenharmony_ci 8318c2ecf20Sopenharmony_cienum jme_ghc_speed_val { 8328c2ecf20Sopenharmony_ci GHC_SPEED_10M = 0x00000010, 8338c2ecf20Sopenharmony_ci GHC_SPEED_100M = 0x00000020, 8348c2ecf20Sopenharmony_ci GHC_SPEED_1000M = 0x00000030, 8358c2ecf20Sopenharmony_ci}; 8368c2ecf20Sopenharmony_ci 8378c2ecf20Sopenharmony_cienum jme_ghc_to_clk { 8388c2ecf20Sopenharmony_ci GHC_TO_CLK_OFF = 0x00000000, 8398c2ecf20Sopenharmony_ci GHC_TO_CLK_GPHY = 0x00400000, 8408c2ecf20Sopenharmony_ci GHC_TO_CLK_PCIE = 0x00800000, 8418c2ecf20Sopenharmony_ci GHC_TO_CLK_INVALID = 0x00C00000, 8428c2ecf20Sopenharmony_ci}; 8438c2ecf20Sopenharmony_ci 8448c2ecf20Sopenharmony_cienum jme_ghc_txmac_clk { 8458c2ecf20Sopenharmony_ci GHC_TXMAC_CLK_OFF = 0x00000000, 8468c2ecf20Sopenharmony_ci GHC_TXMAC_CLK_GPHY = 0x00100000, 8478c2ecf20Sopenharmony_ci GHC_TXMAC_CLK_PCIE = 0x00200000, 8488c2ecf20Sopenharmony_ci GHC_TXMAC_CLK_INVALID = 0x00300000, 8498c2ecf20Sopenharmony_ci}; 8508c2ecf20Sopenharmony_ci 8518c2ecf20Sopenharmony_ci/* 8528c2ecf20Sopenharmony_ci * Power management control and status register 8538c2ecf20Sopenharmony_ci */ 8548c2ecf20Sopenharmony_cienum jme_pmcs_bit_masks { 8558c2ecf20Sopenharmony_ci PMCS_STMASK = 0xFFFF0000, 8568c2ecf20Sopenharmony_ci PMCS_WF7DET = 0x80000000, 8578c2ecf20Sopenharmony_ci PMCS_WF6DET = 0x40000000, 8588c2ecf20Sopenharmony_ci PMCS_WF5DET = 0x20000000, 8598c2ecf20Sopenharmony_ci PMCS_WF4DET = 0x10000000, 8608c2ecf20Sopenharmony_ci PMCS_WF3DET = 0x08000000, 8618c2ecf20Sopenharmony_ci PMCS_WF2DET = 0x04000000, 8628c2ecf20Sopenharmony_ci PMCS_WF1DET = 0x02000000, 8638c2ecf20Sopenharmony_ci PMCS_WF0DET = 0x01000000, 8648c2ecf20Sopenharmony_ci PMCS_LFDET = 0x00040000, 8658c2ecf20Sopenharmony_ci PMCS_LRDET = 0x00020000, 8668c2ecf20Sopenharmony_ci PMCS_MFDET = 0x00010000, 8678c2ecf20Sopenharmony_ci PMCS_ENMASK = 0x0000FFFF, 8688c2ecf20Sopenharmony_ci PMCS_WF7EN = 0x00008000, 8698c2ecf20Sopenharmony_ci PMCS_WF6EN = 0x00004000, 8708c2ecf20Sopenharmony_ci PMCS_WF5EN = 0x00002000, 8718c2ecf20Sopenharmony_ci PMCS_WF4EN = 0x00001000, 8728c2ecf20Sopenharmony_ci PMCS_WF3EN = 0x00000800, 8738c2ecf20Sopenharmony_ci PMCS_WF2EN = 0x00000400, 8748c2ecf20Sopenharmony_ci PMCS_WF1EN = 0x00000200, 8758c2ecf20Sopenharmony_ci PMCS_WF0EN = 0x00000100, 8768c2ecf20Sopenharmony_ci PMCS_LFEN = 0x00000004, 8778c2ecf20Sopenharmony_ci PMCS_LREN = 0x00000002, 8788c2ecf20Sopenharmony_ci PMCS_MFEN = 0x00000001, 8798c2ecf20Sopenharmony_ci}; 8808c2ecf20Sopenharmony_ci 8818c2ecf20Sopenharmony_ci/* 8828c2ecf20Sopenharmony_ci * New PHY Power Control Register 8838c2ecf20Sopenharmony_ci */ 8848c2ecf20Sopenharmony_cienum jme_phy_pwr_bit_masks { 8858c2ecf20Sopenharmony_ci PHY_PWR_DWN1SEL = 0x01000000, /* Phy_giga.p_PWR_DOWN1_SEL */ 8868c2ecf20Sopenharmony_ci PHY_PWR_DWN1SW = 0x02000000, /* Phy_giga.p_PWR_DOWN1_SW */ 8878c2ecf20Sopenharmony_ci PHY_PWR_DWN2 = 0x04000000, /* Phy_giga.p_PWR_DOWN2 */ 8888c2ecf20Sopenharmony_ci PHY_PWR_CLKSEL = 0x08000000, /* 8898c2ecf20Sopenharmony_ci * XTL_OUT Clock select 8908c2ecf20Sopenharmony_ci * (an internal free-running clock) 8918c2ecf20Sopenharmony_ci * 0: xtl_out = phy_giga.A_XTL25_O 8928c2ecf20Sopenharmony_ci * 1: xtl_out = phy_giga.PD_OSC 8938c2ecf20Sopenharmony_ci */ 8948c2ecf20Sopenharmony_ci}; 8958c2ecf20Sopenharmony_ci 8968c2ecf20Sopenharmony_ci/* 8978c2ecf20Sopenharmony_ci * Giga PHY Status Registers 8988c2ecf20Sopenharmony_ci */ 8998c2ecf20Sopenharmony_cienum jme_phy_link_bit_mask { 9008c2ecf20Sopenharmony_ci PHY_LINK_SPEED_MASK = 0x0000C000, 9018c2ecf20Sopenharmony_ci PHY_LINK_DUPLEX = 0x00002000, 9028c2ecf20Sopenharmony_ci PHY_LINK_SPEEDDPU_RESOLVED = 0x00000800, 9038c2ecf20Sopenharmony_ci PHY_LINK_UP = 0x00000400, 9048c2ecf20Sopenharmony_ci PHY_LINK_AUTONEG_COMPLETE = 0x00000200, 9058c2ecf20Sopenharmony_ci PHY_LINK_MDI_STAT = 0x00000040, 9068c2ecf20Sopenharmony_ci}; 9078c2ecf20Sopenharmony_ci 9088c2ecf20Sopenharmony_cienum jme_phy_link_speed_val { 9098c2ecf20Sopenharmony_ci PHY_LINK_SPEED_10M = 0x00000000, 9108c2ecf20Sopenharmony_ci PHY_LINK_SPEED_100M = 0x00004000, 9118c2ecf20Sopenharmony_ci PHY_LINK_SPEED_1000M = 0x00008000, 9128c2ecf20Sopenharmony_ci}; 9138c2ecf20Sopenharmony_ci 9148c2ecf20Sopenharmony_ci#define JME_SPDRSV_TIMEOUT 500 /* 500 us */ 9158c2ecf20Sopenharmony_ci 9168c2ecf20Sopenharmony_ci/* 9178c2ecf20Sopenharmony_ci * SMB Control and Status 9188c2ecf20Sopenharmony_ci */ 9198c2ecf20Sopenharmony_cienum jme_smbcsr_bit_mask { 9208c2ecf20Sopenharmony_ci SMBCSR_CNACK = 0x00020000, 9218c2ecf20Sopenharmony_ci SMBCSR_RELOAD = 0x00010000, 9228c2ecf20Sopenharmony_ci SMBCSR_EEPROMD = 0x00000020, 9238c2ecf20Sopenharmony_ci SMBCSR_INITDONE = 0x00000010, 9248c2ecf20Sopenharmony_ci SMBCSR_BUSY = 0x0000000F, 9258c2ecf20Sopenharmony_ci}; 9268c2ecf20Sopenharmony_ci 9278c2ecf20Sopenharmony_cienum jme_smbintf_bit_mask { 9288c2ecf20Sopenharmony_ci SMBINTF_HWDATR = 0xFF000000, 9298c2ecf20Sopenharmony_ci SMBINTF_HWDATW = 0x00FF0000, 9308c2ecf20Sopenharmony_ci SMBINTF_HWADDR = 0x0000FF00, 9318c2ecf20Sopenharmony_ci SMBINTF_HWRWN = 0x00000020, 9328c2ecf20Sopenharmony_ci SMBINTF_HWCMD = 0x00000010, 9338c2ecf20Sopenharmony_ci SMBINTF_FASTM = 0x00000008, 9348c2ecf20Sopenharmony_ci SMBINTF_GPIOSCL = 0x00000004, 9358c2ecf20Sopenharmony_ci SMBINTF_GPIOSDA = 0x00000002, 9368c2ecf20Sopenharmony_ci SMBINTF_GPIOEN = 0x00000001, 9378c2ecf20Sopenharmony_ci}; 9388c2ecf20Sopenharmony_ci 9398c2ecf20Sopenharmony_cienum jme_smbintf_vals { 9408c2ecf20Sopenharmony_ci SMBINTF_HWRWN_READ = 0x00000020, 9418c2ecf20Sopenharmony_ci SMBINTF_HWRWN_WRITE = 0x00000000, 9428c2ecf20Sopenharmony_ci}; 9438c2ecf20Sopenharmony_ci 9448c2ecf20Sopenharmony_cienum jme_smbintf_shifts { 9458c2ecf20Sopenharmony_ci SMBINTF_HWDATR_SHIFT = 24, 9468c2ecf20Sopenharmony_ci SMBINTF_HWDATW_SHIFT = 16, 9478c2ecf20Sopenharmony_ci SMBINTF_HWADDR_SHIFT = 8, 9488c2ecf20Sopenharmony_ci}; 9498c2ecf20Sopenharmony_ci 9508c2ecf20Sopenharmony_ci#define JME_EEPROM_RELOAD_TIMEOUT 2000 /* 2000 msec */ 9518c2ecf20Sopenharmony_ci#define JME_SMB_BUSY_TIMEOUT 20 /* 20 msec */ 9528c2ecf20Sopenharmony_ci#define JME_SMB_LEN 256 9538c2ecf20Sopenharmony_ci#define JME_EEPROM_MAGIC 0x250 9548c2ecf20Sopenharmony_ci 9558c2ecf20Sopenharmony_ci/* 9568c2ecf20Sopenharmony_ci * Timer Control/Status Register 9578c2ecf20Sopenharmony_ci */ 9588c2ecf20Sopenharmony_cienum jme_tmcsr_bit_masks { 9598c2ecf20Sopenharmony_ci TMCSR_SWIT = 0x80000000, 9608c2ecf20Sopenharmony_ci TMCSR_EN = 0x01000000, 9618c2ecf20Sopenharmony_ci TMCSR_CNT = 0x00FFFFFF, 9628c2ecf20Sopenharmony_ci}; 9638c2ecf20Sopenharmony_ci 9648c2ecf20Sopenharmony_ci/* 9658c2ecf20Sopenharmony_ci * General Purpose REG-0 9668c2ecf20Sopenharmony_ci */ 9678c2ecf20Sopenharmony_cienum jme_gpreg0_masks { 9688c2ecf20Sopenharmony_ci GPREG0_DISSH = 0xFF000000, 9698c2ecf20Sopenharmony_ci GPREG0_PCIRLMT = 0x00300000, 9708c2ecf20Sopenharmony_ci GPREG0_PCCNOMUTCLR = 0x00040000, 9718c2ecf20Sopenharmony_ci GPREG0_LNKINTPOLL = 0x00001000, 9728c2ecf20Sopenharmony_ci GPREG0_PCCTMR = 0x00000300, 9738c2ecf20Sopenharmony_ci GPREG0_PHYADDR = 0x0000001F, 9748c2ecf20Sopenharmony_ci}; 9758c2ecf20Sopenharmony_ci 9768c2ecf20Sopenharmony_cienum jme_gpreg0_vals { 9778c2ecf20Sopenharmony_ci GPREG0_DISSH_DW7 = 0x80000000, 9788c2ecf20Sopenharmony_ci GPREG0_DISSH_DW6 = 0x40000000, 9798c2ecf20Sopenharmony_ci GPREG0_DISSH_DW5 = 0x20000000, 9808c2ecf20Sopenharmony_ci GPREG0_DISSH_DW4 = 0x10000000, 9818c2ecf20Sopenharmony_ci GPREG0_DISSH_DW3 = 0x08000000, 9828c2ecf20Sopenharmony_ci GPREG0_DISSH_DW2 = 0x04000000, 9838c2ecf20Sopenharmony_ci GPREG0_DISSH_DW1 = 0x02000000, 9848c2ecf20Sopenharmony_ci GPREG0_DISSH_DW0 = 0x01000000, 9858c2ecf20Sopenharmony_ci GPREG0_DISSH_ALL = 0xFF000000, 9868c2ecf20Sopenharmony_ci 9878c2ecf20Sopenharmony_ci GPREG0_PCIRLMT_8 = 0x00000000, 9888c2ecf20Sopenharmony_ci GPREG0_PCIRLMT_6 = 0x00100000, 9898c2ecf20Sopenharmony_ci GPREG0_PCIRLMT_5 = 0x00200000, 9908c2ecf20Sopenharmony_ci GPREG0_PCIRLMT_4 = 0x00300000, 9918c2ecf20Sopenharmony_ci 9928c2ecf20Sopenharmony_ci GPREG0_PCCTMR_16ns = 0x00000000, 9938c2ecf20Sopenharmony_ci GPREG0_PCCTMR_256ns = 0x00000100, 9948c2ecf20Sopenharmony_ci GPREG0_PCCTMR_1us = 0x00000200, 9958c2ecf20Sopenharmony_ci GPREG0_PCCTMR_1ms = 0x00000300, 9968c2ecf20Sopenharmony_ci 9978c2ecf20Sopenharmony_ci GPREG0_PHYADDR_1 = 0x00000001, 9988c2ecf20Sopenharmony_ci 9998c2ecf20Sopenharmony_ci GPREG0_DEFAULT = GPREG0_PCIRLMT_4 | 10008c2ecf20Sopenharmony_ci GPREG0_PCCTMR_1us | 10018c2ecf20Sopenharmony_ci GPREG0_PHYADDR_1, 10028c2ecf20Sopenharmony_ci}; 10038c2ecf20Sopenharmony_ci 10048c2ecf20Sopenharmony_ci/* 10058c2ecf20Sopenharmony_ci * General Purpose REG-1 10068c2ecf20Sopenharmony_ci */ 10078c2ecf20Sopenharmony_cienum jme_gpreg1_bit_masks { 10088c2ecf20Sopenharmony_ci GPREG1_RXCLKOFF = 0x04000000, 10098c2ecf20Sopenharmony_ci GPREG1_PCREQN = 0x00020000, 10108c2ecf20Sopenharmony_ci GPREG1_HALFMODEPATCH = 0x00000040, /* For Chip revision 0x11 only */ 10118c2ecf20Sopenharmony_ci GPREG1_RSSPATCH = 0x00000020, /* For Chip revision 0x11 only */ 10128c2ecf20Sopenharmony_ci GPREG1_INTRDELAYUNIT = 0x00000018, 10138c2ecf20Sopenharmony_ci GPREG1_INTRDELAYENABLE = 0x00000007, 10148c2ecf20Sopenharmony_ci}; 10158c2ecf20Sopenharmony_ci 10168c2ecf20Sopenharmony_cienum jme_gpreg1_vals { 10178c2ecf20Sopenharmony_ci GPREG1_INTDLYUNIT_16NS = 0x00000000, 10188c2ecf20Sopenharmony_ci GPREG1_INTDLYUNIT_256NS = 0x00000008, 10198c2ecf20Sopenharmony_ci GPREG1_INTDLYUNIT_1US = 0x00000010, 10208c2ecf20Sopenharmony_ci GPREG1_INTDLYUNIT_16US = 0x00000018, 10218c2ecf20Sopenharmony_ci 10228c2ecf20Sopenharmony_ci GPREG1_INTDLYEN_1U = 0x00000001, 10238c2ecf20Sopenharmony_ci GPREG1_INTDLYEN_2U = 0x00000002, 10248c2ecf20Sopenharmony_ci GPREG1_INTDLYEN_3U = 0x00000003, 10258c2ecf20Sopenharmony_ci GPREG1_INTDLYEN_4U = 0x00000004, 10268c2ecf20Sopenharmony_ci GPREG1_INTDLYEN_5U = 0x00000005, 10278c2ecf20Sopenharmony_ci GPREG1_INTDLYEN_6U = 0x00000006, 10288c2ecf20Sopenharmony_ci GPREG1_INTDLYEN_7U = 0x00000007, 10298c2ecf20Sopenharmony_ci 10308c2ecf20Sopenharmony_ci GPREG1_DEFAULT = GPREG1_PCREQN, 10318c2ecf20Sopenharmony_ci}; 10328c2ecf20Sopenharmony_ci 10338c2ecf20Sopenharmony_ci/* 10348c2ecf20Sopenharmony_ci * Interrupt Status Bits 10358c2ecf20Sopenharmony_ci */ 10368c2ecf20Sopenharmony_cienum jme_interrupt_bits { 10378c2ecf20Sopenharmony_ci INTR_SWINTR = 0x80000000, 10388c2ecf20Sopenharmony_ci INTR_TMINTR = 0x40000000, 10398c2ecf20Sopenharmony_ci INTR_LINKCH = 0x20000000, 10408c2ecf20Sopenharmony_ci INTR_PAUSERCV = 0x10000000, 10418c2ecf20Sopenharmony_ci INTR_MAGICRCV = 0x08000000, 10428c2ecf20Sopenharmony_ci INTR_WAKERCV = 0x04000000, 10438c2ecf20Sopenharmony_ci INTR_PCCRX0TO = 0x02000000, 10448c2ecf20Sopenharmony_ci INTR_PCCRX1TO = 0x01000000, 10458c2ecf20Sopenharmony_ci INTR_PCCRX2TO = 0x00800000, 10468c2ecf20Sopenharmony_ci INTR_PCCRX3TO = 0x00400000, 10478c2ecf20Sopenharmony_ci INTR_PCCTXTO = 0x00200000, 10488c2ecf20Sopenharmony_ci INTR_PCCRX0 = 0x00100000, 10498c2ecf20Sopenharmony_ci INTR_PCCRX1 = 0x00080000, 10508c2ecf20Sopenharmony_ci INTR_PCCRX2 = 0x00040000, 10518c2ecf20Sopenharmony_ci INTR_PCCRX3 = 0x00020000, 10528c2ecf20Sopenharmony_ci INTR_PCCTX = 0x00010000, 10538c2ecf20Sopenharmony_ci INTR_RX3EMP = 0x00008000, 10548c2ecf20Sopenharmony_ci INTR_RX2EMP = 0x00004000, 10558c2ecf20Sopenharmony_ci INTR_RX1EMP = 0x00002000, 10568c2ecf20Sopenharmony_ci INTR_RX0EMP = 0x00001000, 10578c2ecf20Sopenharmony_ci INTR_RX3 = 0x00000800, 10588c2ecf20Sopenharmony_ci INTR_RX2 = 0x00000400, 10598c2ecf20Sopenharmony_ci INTR_RX1 = 0x00000200, 10608c2ecf20Sopenharmony_ci INTR_RX0 = 0x00000100, 10618c2ecf20Sopenharmony_ci INTR_TX7 = 0x00000080, 10628c2ecf20Sopenharmony_ci INTR_TX6 = 0x00000040, 10638c2ecf20Sopenharmony_ci INTR_TX5 = 0x00000020, 10648c2ecf20Sopenharmony_ci INTR_TX4 = 0x00000010, 10658c2ecf20Sopenharmony_ci INTR_TX3 = 0x00000008, 10668c2ecf20Sopenharmony_ci INTR_TX2 = 0x00000004, 10678c2ecf20Sopenharmony_ci INTR_TX1 = 0x00000002, 10688c2ecf20Sopenharmony_ci INTR_TX0 = 0x00000001, 10698c2ecf20Sopenharmony_ci}; 10708c2ecf20Sopenharmony_ci 10718c2ecf20Sopenharmony_cistatic const u32 INTR_ENABLE = INTR_SWINTR | 10728c2ecf20Sopenharmony_ci INTR_TMINTR | 10738c2ecf20Sopenharmony_ci INTR_LINKCH | 10748c2ecf20Sopenharmony_ci INTR_PCCRX0TO | 10758c2ecf20Sopenharmony_ci INTR_PCCRX0 | 10768c2ecf20Sopenharmony_ci INTR_PCCTXTO | 10778c2ecf20Sopenharmony_ci INTR_PCCTX | 10788c2ecf20Sopenharmony_ci INTR_RX0EMP; 10798c2ecf20Sopenharmony_ci 10808c2ecf20Sopenharmony_ci/* 10818c2ecf20Sopenharmony_ci * PCC Control Registers 10828c2ecf20Sopenharmony_ci */ 10838c2ecf20Sopenharmony_cienum jme_pccrx_masks { 10848c2ecf20Sopenharmony_ci PCCRXTO_MASK = 0xFFFF0000, 10858c2ecf20Sopenharmony_ci PCCRX_MASK = 0x0000FF00, 10868c2ecf20Sopenharmony_ci}; 10878c2ecf20Sopenharmony_ci 10888c2ecf20Sopenharmony_cienum jme_pcctx_masks { 10898c2ecf20Sopenharmony_ci PCCTXTO_MASK = 0xFFFF0000, 10908c2ecf20Sopenharmony_ci PCCTX_MASK = 0x0000FF00, 10918c2ecf20Sopenharmony_ci PCCTX_QS_MASK = 0x000000FF, 10928c2ecf20Sopenharmony_ci}; 10938c2ecf20Sopenharmony_ci 10948c2ecf20Sopenharmony_cienum jme_pccrx_shifts { 10958c2ecf20Sopenharmony_ci PCCRXTO_SHIFT = 16, 10968c2ecf20Sopenharmony_ci PCCRX_SHIFT = 8, 10978c2ecf20Sopenharmony_ci}; 10988c2ecf20Sopenharmony_ci 10998c2ecf20Sopenharmony_cienum jme_pcctx_shifts { 11008c2ecf20Sopenharmony_ci PCCTXTO_SHIFT = 16, 11018c2ecf20Sopenharmony_ci PCCTX_SHIFT = 8, 11028c2ecf20Sopenharmony_ci}; 11038c2ecf20Sopenharmony_ci 11048c2ecf20Sopenharmony_cienum jme_pcctx_bits { 11058c2ecf20Sopenharmony_ci PCCTXQ0_EN = 0x00000001, 11068c2ecf20Sopenharmony_ci PCCTXQ1_EN = 0x00000002, 11078c2ecf20Sopenharmony_ci PCCTXQ2_EN = 0x00000004, 11088c2ecf20Sopenharmony_ci PCCTXQ3_EN = 0x00000008, 11098c2ecf20Sopenharmony_ci PCCTXQ4_EN = 0x00000010, 11108c2ecf20Sopenharmony_ci PCCTXQ5_EN = 0x00000020, 11118c2ecf20Sopenharmony_ci PCCTXQ6_EN = 0x00000040, 11128c2ecf20Sopenharmony_ci PCCTXQ7_EN = 0x00000080, 11138c2ecf20Sopenharmony_ci}; 11148c2ecf20Sopenharmony_ci 11158c2ecf20Sopenharmony_ci/* 11168c2ecf20Sopenharmony_ci * Chip Mode Register 11178c2ecf20Sopenharmony_ci */ 11188c2ecf20Sopenharmony_cienum jme_chipmode_bit_masks { 11198c2ecf20Sopenharmony_ci CM_FPGAVER_MASK = 0xFFFF0000, 11208c2ecf20Sopenharmony_ci CM_CHIPREV_MASK = 0x0000FF00, 11218c2ecf20Sopenharmony_ci CM_CHIPMODE_MASK = 0x0000000F, 11228c2ecf20Sopenharmony_ci}; 11238c2ecf20Sopenharmony_ci 11248c2ecf20Sopenharmony_cienum jme_chipmode_shifts { 11258c2ecf20Sopenharmony_ci CM_FPGAVER_SHIFT = 16, 11268c2ecf20Sopenharmony_ci CM_CHIPREV_SHIFT = 8, 11278c2ecf20Sopenharmony_ci}; 11288c2ecf20Sopenharmony_ci 11298c2ecf20Sopenharmony_ci/* 11308c2ecf20Sopenharmony_ci * Aggressive Power Mode Control 11318c2ecf20Sopenharmony_ci */ 11328c2ecf20Sopenharmony_cienum jme_apmc_bits { 11338c2ecf20Sopenharmony_ci JME_APMC_PCIE_SD_EN = 0x40000000, 11348c2ecf20Sopenharmony_ci JME_APMC_PSEUDO_HP_EN = 0x20000000, 11358c2ecf20Sopenharmony_ci JME_APMC_EPIEN = 0x04000000, 11368c2ecf20Sopenharmony_ci JME_APMC_EPIEN_CTRL = 0x03000000, 11378c2ecf20Sopenharmony_ci}; 11388c2ecf20Sopenharmony_ci 11398c2ecf20Sopenharmony_cienum jme_apmc_values { 11408c2ecf20Sopenharmony_ci JME_APMC_EPIEN_CTRL_EN = 0x02000000, 11418c2ecf20Sopenharmony_ci JME_APMC_EPIEN_CTRL_DIS = 0x01000000, 11428c2ecf20Sopenharmony_ci}; 11438c2ecf20Sopenharmony_ci 11448c2ecf20Sopenharmony_ci#define APMC_PHP_SHUTDOWN_DELAY (10 * 1000 * 1000) 11458c2ecf20Sopenharmony_ci 11468c2ecf20Sopenharmony_ci#ifdef REG_DEBUG 11478c2ecf20Sopenharmony_cistatic char *MAC_REG_NAME[] = { 11488c2ecf20Sopenharmony_ci "JME_TXCS", "JME_TXDBA_LO", "JME_TXDBA_HI", "JME_TXQDC", 11498c2ecf20Sopenharmony_ci "JME_TXNDA", "JME_TXMCS", "JME_TXPFC", "JME_TXTRHD", 11508c2ecf20Sopenharmony_ci "JME_RXCS", "JME_RXDBA_LO", "JME_RXDBA_HI", "JME_RXQDC", 11518c2ecf20Sopenharmony_ci "JME_RXNDA", "JME_RXMCS", "JME_RXUMA_LO", "JME_RXUMA_HI", 11528c2ecf20Sopenharmony_ci "JME_RXMCHT_LO", "JME_RXMCHT_HI", "JME_WFODP", "JME_WFOI", 11538c2ecf20Sopenharmony_ci "JME_SMI", "JME_GHC", "UNKNOWN", "UNKNOWN", 11548c2ecf20Sopenharmony_ci "JME_PMCS"}; 11558c2ecf20Sopenharmony_ci 11568c2ecf20Sopenharmony_cistatic char *PE_REG_NAME[] = { 11578c2ecf20Sopenharmony_ci "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN", 11588c2ecf20Sopenharmony_ci "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN", 11598c2ecf20Sopenharmony_ci "UNKNOWN", "UNKNOWN", "JME_PHY_CS", "UNKNOWN", 11608c2ecf20Sopenharmony_ci "JME_PHY_LINK", "UNKNOWN", "UNKNOWN", "UNKNOWN", 11618c2ecf20Sopenharmony_ci "JME_SMBCSR", "JME_SMBINTF"}; 11628c2ecf20Sopenharmony_ci 11638c2ecf20Sopenharmony_cistatic char *MISC_REG_NAME[] = { 11648c2ecf20Sopenharmony_ci "JME_TMCSR", "JME_GPIO", "JME_GPREG0", "JME_GPREG1", 11658c2ecf20Sopenharmony_ci "JME_IEVE", "JME_IREQ", "JME_IENS", "JME_IENC", 11668c2ecf20Sopenharmony_ci "JME_PCCRX0", "JME_PCCRX1", "JME_PCCRX2", "JME_PCCRX3", 11678c2ecf20Sopenharmony_ci "JME_PCCTX0", "JME_CHIPMODE", "JME_SHBA_HI", "JME_SHBA_LO", 11688c2ecf20Sopenharmony_ci "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN", 11698c2ecf20Sopenharmony_ci "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN", 11708c2ecf20Sopenharmony_ci "UNKNOWN", "UNKNOWN", "UNKNOWN", "UNKNOWN", 11718c2ecf20Sopenharmony_ci "JME_TIMER1", "JME_TIMER2", "UNKNOWN", "JME_APMC", 11728c2ecf20Sopenharmony_ci "JME_PCCSRX0"}; 11738c2ecf20Sopenharmony_ci 11748c2ecf20Sopenharmony_cistatic inline void reg_dbg(const struct jme_adapter *jme, 11758c2ecf20Sopenharmony_ci const char *msg, u32 val, u32 reg) 11768c2ecf20Sopenharmony_ci{ 11778c2ecf20Sopenharmony_ci const char *regname; 11788c2ecf20Sopenharmony_ci switch (reg & 0xF00) { 11798c2ecf20Sopenharmony_ci case 0x000: 11808c2ecf20Sopenharmony_ci regname = MAC_REG_NAME[(reg & 0xFF) >> 2]; 11818c2ecf20Sopenharmony_ci break; 11828c2ecf20Sopenharmony_ci case 0x400: 11838c2ecf20Sopenharmony_ci regname = PE_REG_NAME[(reg & 0xFF) >> 2]; 11848c2ecf20Sopenharmony_ci break; 11858c2ecf20Sopenharmony_ci case 0x800: 11868c2ecf20Sopenharmony_ci regname = MISC_REG_NAME[(reg & 0xFF) >> 2]; 11878c2ecf20Sopenharmony_ci break; 11888c2ecf20Sopenharmony_ci default: 11898c2ecf20Sopenharmony_ci regname = PE_REG_NAME[0]; 11908c2ecf20Sopenharmony_ci } 11918c2ecf20Sopenharmony_ci printk(KERN_DEBUG "%s: %-20s %08x@%s\n", jme->dev->name, 11928c2ecf20Sopenharmony_ci msg, val, regname); 11938c2ecf20Sopenharmony_ci} 11948c2ecf20Sopenharmony_ci#else 11958c2ecf20Sopenharmony_cistatic inline void reg_dbg(const struct jme_adapter *jme, 11968c2ecf20Sopenharmony_ci const char *msg, u32 val, u32 reg) {} 11978c2ecf20Sopenharmony_ci#endif 11988c2ecf20Sopenharmony_ci 11998c2ecf20Sopenharmony_ci/* 12008c2ecf20Sopenharmony_ci * Read/Write MMaped I/O Registers 12018c2ecf20Sopenharmony_ci */ 12028c2ecf20Sopenharmony_cistatic inline u32 jread32(struct jme_adapter *jme, u32 reg) 12038c2ecf20Sopenharmony_ci{ 12048c2ecf20Sopenharmony_ci return readl(jme->regs + reg); 12058c2ecf20Sopenharmony_ci} 12068c2ecf20Sopenharmony_ci 12078c2ecf20Sopenharmony_cistatic inline void jwrite32(struct jme_adapter *jme, u32 reg, u32 val) 12088c2ecf20Sopenharmony_ci{ 12098c2ecf20Sopenharmony_ci reg_dbg(jme, "REG WRITE", val, reg); 12108c2ecf20Sopenharmony_ci writel(val, jme->regs + reg); 12118c2ecf20Sopenharmony_ci reg_dbg(jme, "VAL AFTER WRITE", readl(jme->regs + reg), reg); 12128c2ecf20Sopenharmony_ci} 12138c2ecf20Sopenharmony_ci 12148c2ecf20Sopenharmony_cistatic inline void jwrite32f(struct jme_adapter *jme, u32 reg, u32 val) 12158c2ecf20Sopenharmony_ci{ 12168c2ecf20Sopenharmony_ci /* 12178c2ecf20Sopenharmony_ci * Read after write should cause flush 12188c2ecf20Sopenharmony_ci */ 12198c2ecf20Sopenharmony_ci reg_dbg(jme, "REG WRITE FLUSH", val, reg); 12208c2ecf20Sopenharmony_ci writel(val, jme->regs + reg); 12218c2ecf20Sopenharmony_ci readl(jme->regs + reg); 12228c2ecf20Sopenharmony_ci reg_dbg(jme, "VAL AFTER WRITE", readl(jme->regs + reg), reg); 12238c2ecf20Sopenharmony_ci} 12248c2ecf20Sopenharmony_ci 12258c2ecf20Sopenharmony_ci/* 12268c2ecf20Sopenharmony_ci * PHY Regs 12278c2ecf20Sopenharmony_ci */ 12288c2ecf20Sopenharmony_cienum jme_phy_reg17_bit_masks { 12298c2ecf20Sopenharmony_ci PREG17_SPEED = 0xC000, 12308c2ecf20Sopenharmony_ci PREG17_DUPLEX = 0x2000, 12318c2ecf20Sopenharmony_ci PREG17_SPDRSV = 0x0800, 12328c2ecf20Sopenharmony_ci PREG17_LNKUP = 0x0400, 12338c2ecf20Sopenharmony_ci PREG17_MDI = 0x0040, 12348c2ecf20Sopenharmony_ci}; 12358c2ecf20Sopenharmony_ci 12368c2ecf20Sopenharmony_cienum jme_phy_reg17_vals { 12378c2ecf20Sopenharmony_ci PREG17_SPEED_10M = 0x0000, 12388c2ecf20Sopenharmony_ci PREG17_SPEED_100M = 0x4000, 12398c2ecf20Sopenharmony_ci PREG17_SPEED_1000M = 0x8000, 12408c2ecf20Sopenharmony_ci}; 12418c2ecf20Sopenharmony_ci 12428c2ecf20Sopenharmony_ci#define BMSR_ANCOMP 0x0020 12438c2ecf20Sopenharmony_ci 12448c2ecf20Sopenharmony_ci/* 12458c2ecf20Sopenharmony_ci * Workaround 12468c2ecf20Sopenharmony_ci */ 12478c2ecf20Sopenharmony_cistatic inline int is_buggy250(unsigned short device, u8 chiprev) 12488c2ecf20Sopenharmony_ci{ 12498c2ecf20Sopenharmony_ci return device == PCI_DEVICE_ID_JMICRON_JMC250 && chiprev == 0x11; 12508c2ecf20Sopenharmony_ci} 12518c2ecf20Sopenharmony_ci 12528c2ecf20Sopenharmony_cistatic inline int new_phy_power_ctrl(u8 chip_main_rev) 12538c2ecf20Sopenharmony_ci{ 12548c2ecf20Sopenharmony_ci return chip_main_rev >= 5; 12558c2ecf20Sopenharmony_ci} 12568c2ecf20Sopenharmony_ci 12578c2ecf20Sopenharmony_ci/* 12588c2ecf20Sopenharmony_ci * Function prototypes 12598c2ecf20Sopenharmony_ci */ 12608c2ecf20Sopenharmony_cistatic int jme_set_link_ksettings(struct net_device *netdev, 12618c2ecf20Sopenharmony_ci const struct ethtool_link_ksettings *cmd); 12628c2ecf20Sopenharmony_cistatic void jme_set_unicastaddr(struct net_device *netdev); 12638c2ecf20Sopenharmony_cistatic void jme_set_multi(struct net_device *netdev); 12648c2ecf20Sopenharmony_ci 12658c2ecf20Sopenharmony_ci#endif 1266