diff options
Diffstat (limited to 'drivers/staging/wilc1000/wlan.c')
-rw-r--r-- | drivers/staging/wilc1000/wlan.c | 83 |
1 files changed, 49 insertions, 34 deletions
diff --git a/drivers/staging/wilc1000/wlan.c b/drivers/staging/wilc1000/wlan.c index 31f424efe01d..f633c6b9f0a9 100644 --- a/drivers/staging/wilc1000/wlan.c +++ b/drivers/staging/wilc1000/wlan.c @@ -11,7 +11,7 @@ static inline bool is_wilc1000(u32 id) { - return (id & 0xfffff000) == 0x100000; + return (id & (~WILC_CHIP_REV_FIELD)) == WILC_1000_BASE_ID; } static inline void acquire_bus(struct wilc *wilc, enum bus_acquire acquire) @@ -393,10 +393,11 @@ void chip_allow_sleep(struct wilc *wilc) { u32 reg = 0; - wilc->hif_func->hif_read_reg(wilc, 0xf0, ®); + wilc->hif_func->hif_read_reg(wilc, WILC_SDIO_WAKEUP_REG, ®); - wilc->hif_func->hif_write_reg(wilc, 0xf0, reg & ~BIT(0)); - wilc->hif_func->hif_write_reg(wilc, 0xfa, 0); + wilc->hif_func->hif_write_reg(wilc, WILC_SDIO_WAKEUP_REG, + reg & ~WILC_SDIO_WAKEUP_BIT); + wilc->hif_func->hif_write_reg(wilc, WILC_SDIO_HOST_TO_FW_REG, 0); } EXPORT_SYMBOL_GPL(chip_allow_sleep); @@ -407,9 +408,11 @@ void chip_wakeup(struct wilc *wilc) if (wilc->io_type == WILC_HIF_SPI) { do { - h->hif_read_reg(wilc, 1, ®); - h->hif_write_reg(wilc, 1, reg | BIT(1)); - h->hif_write_reg(wilc, 1, reg & ~BIT(1)); + h->hif_read_reg(wilc, WILC_SPI_WAKEUP_REG, ®); + h->hif_write_reg(wilc, WILC_SPI_WAKEUP_REG, + reg | WILC_SPI_WAKEUP_BIT); + h->hif_write_reg(wilc, WILC_SPI_WAKEUP_REG, + reg & ~WILC_SPI_WAKEUP_BIT); do { usleep_range(2000, 2500); @@ -417,35 +420,40 @@ void chip_wakeup(struct wilc *wilc) } while (wilc_get_chipid(wilc, true) == 0); } while (wilc_get_chipid(wilc, true) == 0); } else if (wilc->io_type == WILC_HIF_SDIO) { - h->hif_write_reg(wilc, 0xfa, 1); + h->hif_write_reg(wilc, WILC_SDIO_HOST_TO_FW_REG, + WILC_SDIO_HOST_TO_FW_BIT); usleep_range(200, 400); - h->hif_read_reg(wilc, 0xf0, ®); + h->hif_read_reg(wilc, WILC_SDIO_WAKEUP_REG, ®); do { - h->hif_write_reg(wilc, 0xf0, reg | BIT(0)); - h->hif_read_reg(wilc, 0xf1, &clk_status_reg); + h->hif_write_reg(wilc, WILC_SDIO_WAKEUP_REG, + reg | WILC_SDIO_WAKEUP_BIT); + h->hif_read_reg(wilc, WILC_SDIO_CLK_STATUS_REG, + &clk_status_reg); - while ((clk_status_reg & 0x1) == 0) { + while (!(clk_status_reg & WILC_SDIO_CLK_STATUS_BIT)) { usleep_range(2000, 2500); - h->hif_read_reg(wilc, 0xf1, &clk_status_reg); + h->hif_read_reg(wilc, WILC_SDIO_CLK_STATUS_REG, + &clk_status_reg); } - if ((clk_status_reg & 0x1) == 0) { - h->hif_write_reg(wilc, 0xf0, reg & (~BIT(0))); + if (!(clk_status_reg & WILC_SDIO_CLK_STATUS_BIT)) { + h->hif_write_reg(wilc, WILC_SDIO_WAKEUP_REG, + reg & ~WILC_SDIO_WAKEUP_BIT); } - } while ((clk_status_reg & 0x1) == 0); + } while (!(clk_status_reg & WILC_SDIO_CLK_STATUS_BIT)); } if (wilc->chip_ps_state == WILC_CHIP_SLEEPING_MANUAL) { - if (wilc_get_chipid(wilc, false) < 0x1002b0) { + if (wilc_get_chipid(wilc, false) < WILC_1000_BASE_ID_2B) { u32 val32; - h->hif_read_reg(wilc, 0x1e1c, &val32); + h->hif_read_reg(wilc, WILC_REG_4_TO_1_RX, &val32); val32 |= BIT(6); - h->hif_write_reg(wilc, 0x1e1c, val32); + h->hif_write_reg(wilc, WILC_REG_4_TO_1_RX, val32); - h->hif_read_reg(wilc, 0x1e9c, &val32); + h->hif_read_reg(wilc, WILC_REG_4_TO_1_TX_BANK0, &val32); val32 |= BIT(6); - h->hif_write_reg(wilc, 0x1e9c, val32); + h->hif_write_reg(wilc, WILC_REG_4_TO_1_TX_BANK0, val32); } } wilc->chip_ps_state = WILC_CHIP_WAKEDUP; @@ -455,7 +463,7 @@ EXPORT_SYMBOL_GPL(chip_wakeup); void host_wakeup_notify(struct wilc *wilc) { acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); - wilc->hif_func->hif_write_reg(wilc, 0x10b0, 1); + wilc->hif_func->hif_write_reg(wilc, WILC_CORTUS_INTERRUPT_2, 1); release_bus(wilc, WILC_BUS_RELEASE_ONLY); } EXPORT_SYMBOL_GPL(host_wakeup_notify); @@ -463,7 +471,7 @@ EXPORT_SYMBOL_GPL(host_wakeup_notify); void host_sleep_notify(struct wilc *wilc) { acquire_bus(wilc, WILC_BUS_ACQUIRE_ONLY); - wilc->hif_func->hif_write_reg(wilc, 0x10ac, 1); + wilc->hif_func->hif_write_reg(wilc, WILC_CORTUS_INTERRUPT_1, 1); release_bus(wilc, WILC_BUS_RELEASE_ONLY); } EXPORT_SYMBOL_GPL(host_sleep_notify); @@ -884,7 +892,7 @@ int wilc_wlan_start(struct wilc *wilc) wilc->hif_func->hif_sync_ext(wilc, NUM_INT_EXT); - ret = wilc->hif_func->hif_read_reg(wilc, 0x1000, &chipid); + ret = wilc->hif_func->hif_read_reg(wilc, WILC_CHIPID, &chipid); if (ret) { release_bus(wilc, WILC_BUS_RELEASE_ONLY); return ret; @@ -1125,18 +1133,24 @@ static int init_chip(struct net_device *dev) chipid = wilc_get_chipid(wilc, true); if ((chipid & 0xfff) != 0xa0) { - ret = wilc->hif_func->hif_read_reg(wilc, 0x1118, ®); + ret = wilc->hif_func->hif_read_reg(wilc, + WILC_CORTUS_RESET_MUX_SEL, + ®); if (ret) { netdev_err(dev, "fail read reg 0x1118\n"); goto release; } reg |= BIT(0); - ret = wilc->hif_func->hif_write_reg(wilc, 0x1118, reg); + ret = wilc->hif_func->hif_write_reg(wilc, + WILC_CORTUS_RESET_MUX_SEL, + reg); if (ret) { netdev_err(dev, "fail write reg 0x1118\n"); goto release; } - ret = wilc->hif_func->hif_write_reg(wilc, 0xc0000, 0x71); + ret = wilc->hif_func->hif_write_reg(wilc, + WILC_CORTUS_BOOT_REGISTER, + WILC_CORTUS_BOOT_FROM_IRAM); if (ret) { netdev_err(dev, "fail write reg 0xc0000\n"); goto release; @@ -1156,20 +1170,21 @@ u32 wilc_get_chipid(struct wilc *wilc, bool update) u32 rfrevid = 0; if (chipid == 0 || update) { - wilc->hif_func->hif_read_reg(wilc, 0x1000, &tempchipid); - wilc->hif_func->hif_read_reg(wilc, 0x13f4, &rfrevid); + wilc->hif_func->hif_read_reg(wilc, WILC_CHIPID, &tempchipid); + wilc->hif_func->hif_read_reg(wilc, WILC_RF_REVISION_ID, + &rfrevid); if (!is_wilc1000(tempchipid)) { chipid = 0; return chipid; } - if (tempchipid == 0x1002a0) { + if (tempchipid == WILC_1000_BASE_ID_2A) { /* 0x1002A0 */ if (rfrevid != 0x1) - tempchipid = 0x1002a1; - } else if (tempchipid == 0x1002b0) { + tempchipid = WILC_1000_BASE_ID_2A_REV1; + } else if (tempchipid == WILC_1000_BASE_ID_2B) { /* 0x1002B0 */ if (rfrevid == 0x4) - tempchipid = 0x1002b1; + tempchipid = WILC_1000_BASE_ID_2B_REV1; else if (rfrevid != 0x3) - tempchipid = 0x1002b2; + tempchipid = WILC_1000_BASE_ID_2B_REV2; } chipid = tempchipid; |