common/cnxk: support tunnel header verification
[dpdk.git] / drivers / raw / ifpga / base / opae_intel_max10.h
index 90bf098..e761d7e 100644 (file)
@@ -23,6 +23,11 @@ struct max10_compatible_id {
 #define MAX10_FLAGS_SPI                 BIT(3)
 #define MAX10_FLGAS_NIOS_SPI            BIT(4)
 #define MAX10_FLAGS_PKVL                BIT(5)
+#define MAX10_FLAGS_SECURE             BIT(6)
+#define MAX10_FLAGS_MAC_CACHE          BIT(7)
+
+/** List of opae sensors */
+TAILQ_HEAD(opae_sensor_list, opae_sensor_info);
 
 struct intel_max10_device {
        unsigned int flags; /*max10 hardware capability*/
@@ -30,6 +35,11 @@ struct intel_max10_device {
        struct spi_transaction_dev *spi_tran_dev;
        struct max10_compatible_id *id; /*max10 compatible*/
        char *fdt_root;
+       unsigned int base; /* max10 base address */
+       u16 bus;
+       struct opae_sensor_list opae_sensor_list;
+       u32 staging_area_base;
+       u32 staging_area_size;
 };
 
 /* retimer speed */
@@ -74,37 +84,122 @@ struct opae_retimer_status {
 #define FLASH_BASE 0x10000000
 #define FLASH_OPTION_BITS 0x10000
 
-#define NIOS2_FW_VERSION_OFF   0x300400
-#define RSU_REG_OFF            0x30042c
-#define FPGA_RP_LOAD           BIT(3)
-#define NIOS2_PRERESET         BIT(4)
-#define NIOS2_HANG             BIT(5)
-#define RSU_ENABLE             BIT(6)
-#define NIOS2_RESET            BIT(7)
-#define NIOS2_I2C2_POLL_STOP   BIT(13)
-#define FPGA_RECONF_REG_OFF    0x300430
-#define COUNTDOWN_START                BIT(18)
-#define MAX10_BUILD_VER_OFF    0x300468
-#define PCB_INFO               GENMASK(31, 24)
-#define MAX10_BUILD_VERION     GENMASK(23, 0)
-#define FPGA_PAGE_INFO_OFF     0x30046c
-#define DT_AVAIL_REG_OFF       0x300490
-#define DT_AVAIL               BIT(0)
-#define DT_BASE_ADDR_REG_OFF   0x300494
-#define PKVL_POLLING_CTRL       0x300480
-#define PKVL_LINK_STATUS        0x300564
+/* System Registers */
+#define MAX10_BASE_ADDR                0x300400
+#define MAX10_SEC_BASE_ADDR    0x300800
+/* Register offset of system registers */
+#define NIOS2_FW_VERSION       0x0
+#define MAX10_MACADDR1         0x10
+#define   MAX10_MAC_BYTE4      GENMASK(7, 0)
+#define   MAX10_MAC_BYTE3      GENMASK(15, 8)
+#define   MAX10_MAC_BYTE2      GENMASK(23, 16)
+#define   MAX10_MAC_BYTE1      GENMASK(31, 24)
+#define MAX10_MACADDR2         0x14
+#define   MAX10_MAC_BYTE6      GENMASK(7, 0)
+#define   MAX10_MAC_BYTE5      GENMASK(15, 8)
+#define   MAX10_MAC_COUNT      GENMASK(23, 16)
+#define RSU_REG                        0x2c
+#define   FPGA_RECONF_PAGE     GENMASK(2, 0)
+#define   FPGA_PAGE(p)         ((p) & 0x1)
+#define   FPGA_RP_LOAD         BIT(3)
+#define   NIOS2_PRERESET       BIT(4)
+#define   NIOS2_HANG           BIT(5)
+#define   RSU_ENABLE           BIT(6)
+#define   NIOS2_RESET          BIT(7)
+#define   NIOS2_I2C2_POLL_STOP BIT(13)
+#define   PKVL_EEPROM_LOAD     BIT(31)
+#define FPGA_RECONF_REG                0x30
+#define   SFPGA_RECONF_PAGE    GENMASK(22, 20)
+#define   SFPGA_PAGE(p)                (((p) & 0x1) << 20)
+#define   SFPGA_RP_LOAD                BIT(23)
+#define MAX10_TEST_REG         0x3c
+#define   COUNTDOWN_START      BIT(18)
+#define MAX10_BUILD_VER                0x68
+#define   MAX10_VERSION_MAJOR  GENMASK(23, 16)
+#define   PCB_INFO             GENMASK(31, 24)
+#define FPGA_PAGE_INFO         0x6c
+#define DT_AVAIL_REG           0x90
+#define   DT_AVAIL             BIT(0)
+#define DT_BASE_ADDR_REG       0x94
+#define MAX10_DOORBELL         0x400
+#define   RSU_REQUEST          BIT(0)
+#define   SEC_PROGRESS         GENMASK(7, 4)
+#define   SEC_PROGRESS_G(v)    (((v) >> 4) & 0xf)
+#define   SEC_PROGRESS_IDLE                            0x0
+#define   SEC_PROGRESS_PREPARE                 0x1
+#define   SEC_PROGRESS_SLEEP                   0x2
+#define   SEC_PROGRESS_READY                   0x3
+#define   SEC_PROGRESS_AUTHENTICATING  0x4
+#define   SEC_PROGRESS_COPYING                 0x5
+#define   SEC_PROGRESS_UPDATE_CANCEL   0x6
+#define   SEC_PROGRESS_PROGRAM_KEY_HASH        0x7
+#define   SEC_PROGRESS_RSU_DONE                        0x8
+#define   SEC_PROGRESS_PKVL_PROM_DONE  0x9
+#define   HOST_STATUS          GENMASK(11, 8)
+#define   HOST_STATUS_S(v)     (((v) << 8) & 0xf00)
+#define   HOST_STATUS_IDLE                     0x0
+#define   HOST_STATUS_WRITE_DONE       0x1
+#define   HOST_STATUS_ABORT_RSU                0x2
+#define   SEC_STATUS           GENMASK(23, 16)
+#define   SEC_STATUS_G(v)      (((v) >> 16) & 0xff)
+#define   SEC_STATUS_NORMAL                    0x0
+#define   SEC_STATUS_TIMEOUT           0x1
+#define   SEC_STATUS_AUTH_FAIL         0x2
+#define   SEC_STATUS_COPY_FAIL         0x3
+#define   SEC_STATUS_FATAL                     0x4
+#define   SEC_STATUS_PKVL_REJECT       0x5
+#define   SEC_STATUS_NON_INC           0x6
+#define   SEC_STATUS_ERASE_FAIL                0x7
+#define   SEC_STATUS_WEAROUT           0x8
+#define   SEC_STATUS_NIOS_OK           0x80
+#define   SEC_STATUS_USER_OK           0x81
+#define   SEC_STATUS_FACTORY_OK                0x82
+#define   SEC_STATUS_USER_FAIL         0x83
+#define   SEC_STATUS_FACTORY_FAIL      0x84
+#define   SEC_STATUS_NIOS_FLASH_ERR    0x85
+#define   SEC_STATUS_FPGA_FLASH_ERR    0x86
+#define   CONFIG_SEL           BIT(28)
+#define   CONFIG_SEL_S(v)      (((v) & 0x1) << 28)
+#define   REBOOT_REQ           BIT(29)
+#define MAX10_AUTH_RESULT      0x404
+
+/* PKVL related registers, in system register region */
+#define PKVL_POLLING_CTRL              0x80
+#define   POLLING_MODE                 GENMASK(15, 0)
+#define   PKVL_A_PRELOAD               BIT(16)
+#define   PKVL_A_PRELOAD_TIMEOUT       BIT(17)
+#define   PKVL_A_DATA_TOO_BIG          BIT(18)
+#define   PKVL_A_HDR_CHECKSUM          BIT(20)
+#define   PKVL_B_PRELOAD               BIT(24)
+#define   PKVL_B_PRELOAD_TIMEOUT       BIT(25)
+#define   PKVL_B_DATA_TOO_BIG          BIT(26)
+#define   PKVL_B_HDR_CHECKSUM          BIT(28)
+#define   PKVL_EEPROM_UPG_STATUS       GENMASK(31, 16)
+#define PKVL_LINK_STATUS               0x164
+#define PKVL_A_VERSION                 0x254
+#define PKVL_B_VERSION                 0x258
+#define   SERDES_VERSION               GENMASK(15, 0)
+#define   SBUS_VERSION                 GENMASK(31, 16)
 
 #define DFT_MAX_SIZE           0x7e0000
+#define MAX_STAGING_AREA_BASE  0xffffffff
+#define MAX_STAGING_AREA_SIZE  0x3800000
 
-int max10_reg_read(unsigned int reg, unsigned int *val);
-int max10_reg_write(unsigned int reg, unsigned int val);
+int max10_reg_read(struct intel_max10_device *dev,
+       unsigned int reg, unsigned int *val);
+int max10_reg_write(struct intel_max10_device *dev,
+       unsigned int reg, unsigned int val);
+int max10_sys_read(struct intel_max10_device *dev,
+       unsigned int offset, unsigned int *val);
+int max10_sys_write(struct intel_max10_device *dev,
+       unsigned int offset, unsigned int val);
+int max10_sys_update_bits(struct intel_max10_device *dev,
+       unsigned int offset, unsigned int msk, unsigned int val);
 struct intel_max10_device *
 intel_max10_device_probe(struct altera_spi_device *spi,
                int chipselect);
 int intel_max10_device_remove(struct intel_max10_device *dev);
 
-/** List of opae sensors */
-TAILQ_HEAD(opae_sensor_list, opae_sensor_info);
 
 #define SENSOR_REG_VALUE 0x0
 #define SENSOR_REG_HIGH_WARN 0x1