diff options
Diffstat (limited to 'drivers/net/sfc/falcon.c')
-rw-r--r-- | drivers/net/sfc/falcon.c | 114 |
1 files changed, 44 insertions, 70 deletions
diff --git a/drivers/net/sfc/falcon.c b/drivers/net/sfc/falcon.c index 511308560487..2ef876d8f233 100644 --- a/drivers/net/sfc/falcon.c +++ b/drivers/net/sfc/falcon.c | |||
@@ -70,6 +70,20 @@ static int disable_dma_stats; | |||
70 | #define RX_DC_ENTRIES_ORDER 2 | 70 | #define RX_DC_ENTRIES_ORDER 2 |
71 | #define RX_DC_BASE 0x100000 | 71 | #define RX_DC_BASE 0x100000 |
72 | 72 | ||
73 | static const unsigned int | ||
74 | /* "Large" EEPROM device: Atmel AT25640 or similar | ||
75 | * 8 KB, 16-bit address, 32 B write block */ | ||
76 | large_eeprom_type = ((13 << SPI_DEV_TYPE_SIZE_LBN) | ||
77 | | (2 << SPI_DEV_TYPE_ADDR_LEN_LBN) | ||
78 | | (5 << SPI_DEV_TYPE_BLOCK_SIZE_LBN)), | ||
79 | /* Default flash device: Atmel AT25F1024 | ||
80 | * 128 KB, 24-bit address, 32 KB erase block, 256 B write block */ | ||
81 | default_flash_type = ((17 << SPI_DEV_TYPE_SIZE_LBN) | ||
82 | | (3 << SPI_DEV_TYPE_ADDR_LEN_LBN) | ||
83 | | (0x52 << SPI_DEV_TYPE_ERASE_CMD_LBN) | ||
84 | | (15 << SPI_DEV_TYPE_ERASE_SIZE_LBN) | ||
85 | | (8 << SPI_DEV_TYPE_BLOCK_SIZE_LBN)); | ||
86 | |||
73 | /* RX FIFO XOFF watermark | 87 | /* RX FIFO XOFF watermark |
74 | * | 88 | * |
75 | * When the amount of the RX FIFO increases used increases past this | 89 | * When the amount of the RX FIFO increases used increases past this |
@@ -2270,12 +2284,15 @@ int falcon_read_nvram(struct efx_nic *efx, struct falcon_nvconfig *nvconfig_out) | |||
2270 | __le16 *word, *limit; | 2284 | __le16 *word, *limit; |
2271 | u32 csum; | 2285 | u32 csum; |
2272 | 2286 | ||
2287 | spi = efx->spi_flash ? efx->spi_flash : efx->spi_eeprom; | ||
2288 | if (!spi) | ||
2289 | return -EINVAL; | ||
2290 | |||
2273 | region = kmalloc(FALCON_NVCONFIG_END, GFP_KERNEL); | 2291 | region = kmalloc(FALCON_NVCONFIG_END, GFP_KERNEL); |
2274 | if (!region) | 2292 | if (!region) |
2275 | return -ENOMEM; | 2293 | return -ENOMEM; |
2276 | nvconfig = region + NVCONFIG_OFFSET; | 2294 | nvconfig = region + NVCONFIG_OFFSET; |
2277 | 2295 | ||
2278 | spi = efx->spi_flash ? efx->spi_flash : efx->spi_eeprom; | ||
2279 | mutex_lock(&efx->spi_lock); | 2296 | mutex_lock(&efx->spi_lock); |
2280 | rc = falcon_spi_read(spi, 0, FALCON_NVCONFIG_END, NULL, region); | 2297 | rc = falcon_spi_read(spi, 0, FALCON_NVCONFIG_END, NULL, region); |
2281 | mutex_unlock(&efx->spi_lock); | 2298 | mutex_unlock(&efx->spi_lock); |
@@ -2713,80 +2730,37 @@ static int falcon_probe_nic_variant(struct efx_nic *efx) | |||
2713 | static void falcon_probe_spi_devices(struct efx_nic *efx) | 2730 | static void falcon_probe_spi_devices(struct efx_nic *efx) |
2714 | { | 2731 | { |
2715 | efx_oword_t nic_stat, gpio_ctl, ee_vpd_cfg; | 2732 | efx_oword_t nic_stat, gpio_ctl, ee_vpd_cfg; |
2716 | bool has_flash, has_eeprom, boot_is_external; | 2733 | int boot_dev; |
2717 | 2734 | ||
2718 | falcon_read(efx, &gpio_ctl, GPIO_CTL_REG_KER); | 2735 | falcon_read(efx, &gpio_ctl, GPIO_CTL_REG_KER); |
2719 | falcon_read(efx, &nic_stat, NIC_STAT_REG); | 2736 | falcon_read(efx, &nic_stat, NIC_STAT_REG); |
2720 | falcon_read(efx, &ee_vpd_cfg, EE_VPD_CFG_REG_KER); | 2737 | falcon_read(efx, &ee_vpd_cfg, EE_VPD_CFG_REG_KER); |
2721 | 2738 | ||
2722 | has_flash = EFX_OWORD_FIELD(nic_stat, SF_PRST); | 2739 | if (EFX_OWORD_FIELD(gpio_ctl, BOOTED_USING_NVDEVICE)) { |
2723 | has_eeprom = EFX_OWORD_FIELD(nic_stat, EE_PRST); | 2740 | boot_dev = (EFX_OWORD_FIELD(nic_stat, SF_PRST) ? |
2724 | boot_is_external = EFX_OWORD_FIELD(gpio_ctl, BOOTED_USING_NVDEVICE); | 2741 | EE_SPI_FLASH : EE_SPI_EEPROM); |
2725 | 2742 | EFX_LOG(efx, "Booted from %s\n", | |
2726 | if (has_flash) { | 2743 | boot_dev == EE_SPI_FLASH ? "flash" : "EEPROM"); |
2727 | /* Default flash SPI device: Atmel AT25F1024 | 2744 | } else { |
2728 | * 128 KB, 24-bit address, 32 KB erase block, | 2745 | /* Disable VPD and set clock dividers to safe |
2729 | * 256 B write block | 2746 | * values for initial programming. */ |
2730 | */ | 2747 | boot_dev = -1; |
2731 | u32 flash_device_type = | 2748 | EFX_LOG(efx, "Booted from internal ASIC settings;" |
2732 | (17 << SPI_DEV_TYPE_SIZE_LBN) | 2749 | " setting SPI config\n"); |
2733 | | (3 << SPI_DEV_TYPE_ADDR_LEN_LBN) | 2750 | EFX_POPULATE_OWORD_3(ee_vpd_cfg, EE_VPD_EN, 0, |
2734 | | (0x52 << SPI_DEV_TYPE_ERASE_CMD_LBN) | 2751 | /* 125 MHz / 7 ~= 20 MHz */ |
2735 | | (15 << SPI_DEV_TYPE_ERASE_SIZE_LBN) | 2752 | EE_SF_CLOCK_DIV, 7, |
2736 | | (8 << SPI_DEV_TYPE_BLOCK_SIZE_LBN); | 2753 | /* 125 MHz / 63 ~= 2 MHz */ |
2737 | 2754 | EE_EE_CLOCK_DIV, 63); | |
2738 | falcon_spi_device_init(efx, &efx->spi_flash, | 2755 | falcon_write(efx, &ee_vpd_cfg, EE_VPD_CFG_REG_KER); |
2739 | EE_SPI_FLASH, flash_device_type); | 2756 | } |
2740 | 2757 | ||
2741 | if (!boot_is_external) { | 2758 | if (boot_dev == EE_SPI_FLASH) |
2742 | /* Disable VPD and set clock dividers to safe | 2759 | falcon_spi_device_init(efx, &efx->spi_flash, EE_SPI_FLASH, |
2743 | * values for initial programming. | 2760 | default_flash_type); |
2744 | */ | 2761 | if (boot_dev == EE_SPI_EEPROM) |
2745 | EFX_LOG(efx, "Booted from internal ASIC settings;" | 2762 | falcon_spi_device_init(efx, &efx->spi_eeprom, EE_SPI_EEPROM, |
2746 | " setting SPI config\n"); | 2763 | large_eeprom_type); |
2747 | EFX_POPULATE_OWORD_3(ee_vpd_cfg, EE_VPD_EN, 0, | ||
2748 | /* 125 MHz / 7 ~= 20 MHz */ | ||
2749 | EE_SF_CLOCK_DIV, 7, | ||
2750 | /* 125 MHz / 63 ~= 2 MHz */ | ||
2751 | EE_EE_CLOCK_DIV, 63); | ||
2752 | falcon_write(efx, &ee_vpd_cfg, EE_VPD_CFG_REG_KER); | ||
2753 | } | ||
2754 | } | ||
2755 | |||
2756 | if (has_eeprom) { | ||
2757 | u32 eeprom_device_type; | ||
2758 | |||
2759 | /* If it has no flash, it must have a large EEPROM | ||
2760 | * for chip config; otherwise check whether 9-bit | ||
2761 | * addressing is used for VPD configuration | ||
2762 | */ | ||
2763 | if (has_flash && | ||
2764 | (!boot_is_external || | ||
2765 | EFX_OWORD_FIELD(ee_vpd_cfg, EE_VPD_EN_AD9_MODE))) { | ||
2766 | /* Default SPI device: Atmel AT25040 or similar | ||
2767 | * 512 B, 9-bit address, 8 B write block | ||
2768 | */ | ||
2769 | eeprom_device_type = | ||
2770 | (9 << SPI_DEV_TYPE_SIZE_LBN) | ||
2771 | | (1 << SPI_DEV_TYPE_ADDR_LEN_LBN) | ||
2772 | | (3 << SPI_DEV_TYPE_BLOCK_SIZE_LBN); | ||
2773 | } else { | ||
2774 | /* "Large" SPI device: Atmel AT25640 or similar | ||
2775 | * 8 KB, 16-bit address, 32 B write block | ||
2776 | */ | ||
2777 | eeprom_device_type = | ||
2778 | (13 << SPI_DEV_TYPE_SIZE_LBN) | ||
2779 | | (2 << SPI_DEV_TYPE_ADDR_LEN_LBN) | ||
2780 | | (5 << SPI_DEV_TYPE_BLOCK_SIZE_LBN); | ||
2781 | } | ||
2782 | |||
2783 | falcon_spi_device_init(efx, &efx->spi_eeprom, | ||
2784 | EE_SPI_EEPROM, eeprom_device_type); | ||
2785 | } | ||
2786 | |||
2787 | EFX_LOG(efx, "flash is %s, EEPROM is %s\n", | ||
2788 | (has_flash ? "present" : "absent"), | ||
2789 | (has_eeprom ? "present" : "absent")); | ||
2790 | } | 2764 | } |
2791 | 2765 | ||
2792 | int falcon_probe_nic(struct efx_nic *efx) | 2766 | int falcon_probe_nic(struct efx_nic *efx) |