Skip to content

Commit 79de7b3

Browse files
ajaykathatajaysk
authored andcommitted
wilc1000: loaded wilc3000 FW
Signed-off-by: Ajay Singh <ajay.kathat@microchip.com>
1 parent 1e3d27f commit 79de7b3

1 file changed

Lines changed: 37 additions & 18 deletions

File tree

  • drivers/net/wireless/microchip/wilc1000

drivers/net/wireless/microchip/wilc1000/netdev.c

Lines changed: 37 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
#define __WILC1000_FW(api) WILC1000_FW_PREFIX #api ".bin"
2323
#define WILC1000_FW(api) __WILC1000_FW(api)
2424

25+
#define WILC3000_API_VER 1
26+
27+
#define WILC3000_FW_PREFIX "atmel/wilc3000_wifi_firmware-"
28+
#define __WILC3000_FW(api) WILC3000_FW_PREFIX #api ".bin"
29+
#define WILC3000_FW(api) __WILC3000_FW(api)
30+
2531
static int wilc_mac_open(struct net_device *ndev);
2632
static int wilc_mac_close(struct net_device *ndev);
2733

@@ -370,20 +376,31 @@ static int wilc_wlan_get_firmware(struct net_device *dev)
370376
{
371377
struct wilc_vif *vif = netdev_priv(dev);
372378
struct wilc *wilc = vif->wilc;
373-
int chip_id;
374379
const struct firmware *wilc_fw;
380+
char *firmware;
375381
int ret;
376382

377-
chip_id = wilc_get_chipid(wilc, false);
383+
if (wilc->chip == WILC_3000) {
384+
PRINT_INFO(dev, INIT_DBG, "Detect chip WILC3000\n");
385+
firmware = WILC3000_FW(WILC3000_API_VER);
386+
} else if (wilc->chip == WILC_1000) {
387+
PRINT_INFO(dev, INIT_DBG, "Detect chip WILC1000\n");
388+
firmware = WILC1000_FW(WILC1000_API_VER);
389+
} else {
390+
return -EINVAL;
391+
}
392+
393+
PRINT_INFO(dev, INIT_DBG, "loading firmware %s\n", firmware);
378394

379-
netdev_info(dev, "ChipID [%x] loading firmware [%s]\n", chip_id,
380-
WILC1000_FW(WILC1000_API_VER));
395+
if (!(&vif->ndev->dev)) {
396+
PRINT_ER(dev, "Dev is NULL\n");
397+
return -EINVAL;
398+
}
381399

382-
ret = request_firmware(&wilc_fw, WILC1000_FW(WILC1000_API_VER),
383-
wilc->dev);
400+
PRINT_INFO(vif->ndev, INIT_DBG, "WLAN firmware: %s\n", firmware);
401+
ret = request_firmware(&wilc_fw, firmware, wilc->dev);
384402
if (ret != 0) {
385-
netdev_err(dev, "%s - firmware not available\n",
386-
WILC1000_FW(WILC1000_API_VER));
403+
PRINT_ER(dev, "%s - firmware not available\n", firmware);
387404
return -EINVAL;
388405
}
389406
wilc->firmware = wilc_fw;
@@ -416,28 +433,29 @@ static int wilc_start_firmware(struct net_device *dev)
416433
return 0;
417434
}
418435

419-
static int wilc1000_firmware_download(struct net_device *dev)
436+
static int wilc_firmware_download(struct net_device *dev)
420437
{
421438
struct wilc_vif *vif = netdev_priv(dev);
422439
struct wilc *wilc = vif->wilc;
423440
int ret = 0;
424441

425442
if (!wilc->firmware) {
426-
netdev_err(dev, "Firmware buffer is NULL\n");
427-
return -ENOBUFS;
443+
PRINT_ER(dev, "Firmware buffer is NULL\n");
444+
ret = -ENOBUFS;
428445
}
429-
446+
PRINT_INFO(vif->ndev, INIT_DBG, "Downloading Firmware ...\n");
430447
ret = wilc_wlan_firmware_download(wilc, wilc->firmware->data,
431448
wilc->firmware->size);
432-
if (ret)
433-
return ret;
449+
if (ret < 0)
450+
goto fail;
451+
452+
PRINT_INFO(vif->ndev, INIT_DBG, "Download Succeeded\n");
434453

454+
fail:
435455
release_firmware(wilc->firmware);
436456
wilc->firmware = NULL;
437457

438-
netdev_dbg(dev, "Download Succeeded\n");
439-
440-
return 0;
458+
return ret;
441459
}
442460

443461
static int wilc_init_fw_config(struct net_device *dev, struct wilc_vif *vif)
@@ -762,7 +780,7 @@ static int wilc_wlan_initialize(struct net_device *dev, struct wilc_vif *vif)
762780
goto fail_irq_enable;
763781
}
764782

765-
ret = wilc1000_firmware_download(dev);
783+
ret = wilc_firmware_download(dev);
766784
if (ret) {
767785
PRINT_ER(dev, "Failed to download firmware\n");
768786
goto fail_irq_enable;
@@ -1324,3 +1342,4 @@ struct wilc_vif *wilc_netdev_ifc_init(struct wilc *wl, const char *name,
13241342

13251343
MODULE_LICENSE("GPL");
13261344
MODULE_FIRMWARE(WILC1000_FW(WILC1000_API_VER));
1345+
MODULE_FIRMWARE(WILC3000_FW(WILC3000_API_VER));

0 commit comments

Comments
 (0)