command: Remove the cmd_tbl_t typedef
[oweals/u-boot.git] / drivers / net / e1000.h
index ff87af2ef8a4a877a496e3dc58fe005ccaff7580..19ed4777d9ab693eed0288b4fea04d03247cefc9 100644 (file)
@@ -1,11 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
 /*******************************************************************************
 
 
   Copyright(c) 1999 - 2002 Intel Corporation. All rights reserved.
   Copyright 2011 Freescale Semiconductor, Inc.
 
- * SPDX-License-Identifier:    GPL-2.0+
-
   Contact Information:
   Linux NICS <linux.nics@intel.com>
   Intel Corporation, 5200 N.E. Elam Young Parkway, Hillsboro, OR 97124-6497
 #ifndef _E1000_HW_H_
 #define _E1000_HW_H_
 
-#include <common.h>
 #include <linux/list.h>
 #include <malloc.h>
 #include <net.h>
+/* Avoids a compile error since struct eth_device is not defined */
+#ifndef CONFIG_DM_ETH
 #include <netdev.h>
+#endif
 #include <asm/io.h>
 #include <pci.h>
 
@@ -73,8 +74,8 @@ void e1000_lower_ee_clk(struct e1000_hw *hw, uint32_t *eecd);
 #endif
 
 #ifdef CONFIG_E1000_SPI
-int do_e1000_spi(cmd_tbl_t *cmdtp, struct e1000_hw *hw,
-               int argc, char * const argv[]);
+int do_e1000_spi(struct cmd_tbl *cmdtp, struct e1000_hw *hw,
+                int argc, char *const argv[]);
 #endif
 
 /* Enumerated types specific to the e1000 hardware */
@@ -100,6 +101,7 @@ typedef enum {
        e1000_82574,
        e1000_80003es2lan,
        e1000_ich8lan,
+       e1000_igb,
        e1000_num_macs
 } e1000_mac_type;
 
@@ -118,6 +120,7 @@ typedef enum {
        e1000_eeprom_flash,
        e1000_eeprom_ich8,
        e1000_eeprom_none, /* No NVM support */
+       e1000_eeprom_invm,
        e1000_num_eeprom_types
 } e1000_eeprom_type;
 
@@ -212,6 +215,7 @@ typedef enum {
        e1000_phy_gg82563,
        e1000_phy_igp_3,
        e1000_phy_ife,
+       e1000_phy_igb,
        e1000_phy_bm,
        e1000_phy_undefined = 0xFF
 } e1000_phy_type;
@@ -427,12 +431,11 @@ struct e1000_phy_stats {
 #define ENET_HEADER_SIZE            14
 #define MAXIMUM_ETHERNET_FRAME_SIZE  1518      /* With FCS */
 #define MINIMUM_ETHERNET_FRAME_SIZE  64        /* With FCS */
-#define ETHERNET_FCS_SIZE           4
 #define MAXIMUM_ETHERNET_PACKET_SIZE \
-    (MAXIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
+       (MAXIMUM_ETHERNET_FRAME_SIZE - ETH_FCS_LEN)
 #define MINIMUM_ETHERNET_PACKET_SIZE \
-    (MINIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE)
-#define CRC_LENGTH                  ETHERNET_FCS_SIZE
+       (MINIMUM_ETHERNET_FRAME_SIZE - ETH_FCS_LEN)
+#define CRC_LENGTH                  ETH_FCS_LEN
 #define MAX_JUMBO_FRAME_SIZE        0x3F00
 
 /* 802.1q VLAN Packet Sizes */
@@ -686,7 +689,9 @@ struct e1000_ffvt_entry {
 #define E1000_CTRL     0x00000 /* Device Control - RW */
 #define E1000_STATUS   0x00008 /* Device Status - RO */
 #define E1000_EECD     0x00010 /* EEPROM/Flash Control - RW */
+#define E1000_I210_EECD     0x12010    /* EEPROM/Flash Control - RW */
 #define E1000_EERD     0x00014 /* EEPROM Read - RW */
+#define E1000_I210_EERD     0x12014    /* EEPROM Read - RW */
 #define E1000_CTRL_EXT 0x00018 /* Extended Device Control - RW */
 #define E1000_MDIC     0x00020 /* MDI Control - RW */
 #define E1000_FCAL     0x00028 /* Flow Control Address Low - RW */
@@ -698,6 +703,7 @@ struct e1000_ffvt_entry {
 #define E1000_ICS      0x000C8 /* Interrupt Cause Set - WO */
 #define E1000_IMS      0x000D0 /* Interrupt Mask Set - RW */
 #define E1000_IMC      0x000D8 /* Interrupt Mask Clear - WO */
+#define E1000_I210_IAM      0x000E0    /* Interrupt Ack Auto Mask - RW */
 #define E1000_RCTL     0x00100 /* RX Control - RW */
 #define E1000_FCTTV    0x00170 /* Flow Control Transmit Timer Value - RW */
 #define E1000_TXCW     0x00178 /* TX Configuration Word - RW */
@@ -711,14 +717,17 @@ struct e1000_ffvt_entry {
 #define E1000_EXTCNF_CTRL  0x00F00  /* Extended Configuration Control */
 #define E1000_EXTCNF_SIZE  0x00F08  /* Extended Configuration Size */
 #define E1000_PHY_CTRL     0x00F10  /* PHY Control Register in CSR */
+#define E1000_I210_PHY_CTRL     0x00E14  /* PHY Control Register in CSR */
 #define FEXTNVM_SW_CONFIG  0x0001
 #define E1000_PBA      0x01000 /* Packet Buffer Allocation - RW */
 #define E1000_PBS      0x01008  /* Packet Buffer Size */
 #define E1000_EEMNGCTL 0x01010  /* MNG EEprom Control */
+#define E1000_I210_EEMNGCTL 0x12030  /* MNG EEprom Control */
 #define E1000_FLASH_UPDATES 1000
 #define E1000_EEARBC   0x01024  /* EEPROM Auto Read Bus Control */
 #define E1000_FLASHT   0x01028  /* FLASH Timer Register */
 #define E1000_EEWR     0x0102C  /* EEPROM Write Register - RW */
+#define E1000_I210_EEWR     0x12018  /* EEPROM Write Register - RW */
 #define E1000_FLSWCTL  0x01030  /* FLASH control register */
 #define E1000_FLSWDATA 0x01034  /* FLASH data register */
 #define E1000_FLSWCNT  0x01038  /* FLASH Access Counter */
@@ -1064,14 +1073,21 @@ typedef enum {
 
 /* Structure containing variables used by the shared code (e1000_hw.c) */
 struct e1000_hw {
+       const char *name;
        struct list_head list_node;
+#ifndef CONFIG_DM_ETH
        struct eth_device *nic;
+#endif
 #ifdef CONFIG_E1000_SPI
        struct spi_slave spi;
 #endif
        unsigned int cardnum;
 
+#ifdef CONFIG_DM_ETH
+       struct udevice *pdev;
+#else
        pci_dev_t pdev;
+#endif
        uint8_t *hw_addr;
        e1000_mac_type mac_type;
        e1000_phy_type phy_type;
@@ -1080,11 +1096,6 @@ struct e1000_hw {
        e1000_media_type media_type;
        e1000_fc_type fc;
        e1000_bus_type bus_type;
-#if 0
-       e1000_bus_speed bus_speed;
-       e1000_bus_width bus_width;
-       uint32_t io_base;
-#endif
        uint32_t                asf_firmware_present;
 #ifndef CONFIG_E1000_NO_NVM
        uint32_t                eeprom_semaphore_present;
@@ -1103,29 +1114,11 @@ struct e1000_hw {
        uint32_t original_fc;
        uint32_t txcw;
        uint32_t autoneg_failed;
-#if 0
-       uint32_t max_frame_size;
-       uint32_t min_frame_size;
-       uint32_t mc_filter_type;
-       uint32_t num_mc_addrs;
-       uint32_t collision_delta;
-       uint32_t tx_packet_delta;
-       uint32_t ledctl_default;
-       uint32_t ledctl_mode1;
-       uint32_t ledctl_mode2;
-#endif
        uint16_t autoneg_advertised;
        uint16_t pci_cmd_word;
        uint16_t fc_high_water;
        uint16_t fc_low_water;
        uint16_t fc_pause_time;
-#if 0
-       uint16_t current_ifs_val;
-       uint16_t ifs_min_val;
-       uint16_t ifs_max_val;
-       uint16_t ifs_step_size;
-       uint16_t ifs_ratio;
-#endif
        uint16_t device_id;
        uint16_t vendor_id;
        uint16_t subsystem_id;
@@ -1136,9 +1129,6 @@ struct e1000_hw {
        uint8_t forced_speed_duplex;
        uint8_t wait_autoneg_complete;
        uint8_t dma_fairness;
-#if 0
-       uint8_t perm_mac_addr[NODE_ADDRESS_SIZE];
-#endif
        bool disable_polarity_correction;
        bool            speed_downgraded;
        bool get_link_status;
@@ -1149,11 +1139,6 @@ struct e1000_hw {
        bool report_tx_early;
        bool phy_reset_disable;
        bool            initialize_hw_bits_disable;
-#if 0
-       bool adaptive_ifs;
-       bool ifs_params_forced;
-       bool in_ifs_mode;
-#endif
        e1000_smart_speed       smart_speed;
        e1000_dsp_config        dsp_config_state;
 };
@@ -1222,6 +1207,7 @@ struct e1000_hw {
 #define E1000_STATUS_BUS64     0x00001000      /* In 64 bit slot */
 #define E1000_STATUS_PCIX_MODE 0x00002000      /* PCI-X mode */
 #define E1000_STATUS_PCIX_SPEED 0x0000C000     /* PCI-X bus speed */
+#define E1000_STATUS_PF_RST_DONE 0x00200000    /* PCI-X bus speed */
 
 /* Constants used to intrepret the masked PCI-X bus speed. */
 #define E1000_STATUS_PCIX_SPEED_66  0x00000000 /* PCI-X bus speed  50-66 MHz */
@@ -1255,6 +1241,9 @@ struct e1000_hw {
 #define E1000_EECD_SELSHAD   0x00020000 /* Select Shadow RAM */
 #define E1000_EECD_INITSRAM  0x00040000 /* Initialize Shadow RAM */
 #define E1000_EECD_FLUPD     0x00080000 /* Update FLASH */
+#define E1000_EECD_FLUPD_I210       0x00800000 /* Update FLASH */
+#define E1000_EECD_FLUDONE_I210     0x04000000 /* Update FLASH done*/
+#define E1000_FLUDONE_ATTEMPTS      20000
 #define E1000_EECD_AUPDEN    0x00100000 /* Enable Autonomous FLASH update */
 #define E1000_EECD_SHADV     0x00200000 /* Shadow RAM Data Valid */
 #define E1000_EECD_SEC1VAL   0x00400000 /* Sector One Valid */
@@ -2438,6 +2427,8 @@ struct e1000_hw {
 
 #define BME1000_E_PHY_ID     0x01410CB0
 
+#define I210_I_PHY_ID          0x01410C00
+
 /* Miscellaneous PHY bit definitions. */
 #define PHY_PREAMBLE                   0xFFFFFFFF
 #define PHY_SOF                                0x01
@@ -2449,7 +2440,7 @@ struct e1000_hw {
 #define MII_CR_SPEED_100               0x2000
 #define MII_CR_SPEED_10                0x0000
 #define E1000_PHY_ADDRESS              0x01
-#define PHY_AUTO_NEG_TIME              45      /* 4.5 Seconds */
+#define PHY_AUTO_NEG_TIME              80      /* 8.0 Seconds */
 #define PHY_FORCE_TIME                 20      /* 2.0 Seconds */
 #define PHY_REVISION_MASK              0xFFFFFFF0
 #define DEVICE_SPEED_MASK              0x00000300      /* Device Ctrl Reg Speed Mask */