static int wl1271_op_start(struct ieee80211_hw *hw) { struct wl1271 *wl = hw->priv; int ret = 0; wl1271_debug(DEBUG_MAC80211, "mac80211 start"); mutex_lock(&wl->mutex); if (wl->state != WL1271_STATE_OFF) { wl1271_error("cannot start because not in off state: %d", wl->state); ret = -EBUSY; goto out; } ret = wl1271_chip_wakeup(wl); if (ret < 0) goto out; ret = wl1271_boot(wl); if (ret < 0) goto out; ret = wl1271_hw_init(wl); if (ret < 0) goto out; wl->state = WL1271_STATE_ON; wl1271_info("firmware booted (%s)", wl->chip.fw_ver); out: if (ret < 0) wl1271_power_off(wl); mutex_unlock(&wl->mutex); return ret; }
int wl1271_plt_start(struct wl1271 *wl) { int ret; mutex_lock(&wl->mutex); wl1271_notice("power up"); if (wl->state != WL1271_STATE_OFF) { wl1271_error("cannot go into PLT state because not " "in off state: %d", wl->state); ret = -EBUSY; goto out; } wl->state = WL1271_STATE_PLT; ret = wl1271_chip_wakeup(wl); if (ret < 0) goto out; ret = wl1271_boot(wl); if (ret < 0) goto out; wl1271_notice("firmware booted in PLT mode (%s)", wl->chip.fw_ver); ret = wl1271_plt_init(wl); if (ret < 0) goto out; out: mutex_unlock(&wl->mutex); return ret; }
static int __devinit wl1271_probe(struct sdio_func *func, const struct sdio_device_id *id) { const struct wl12xx_platform_data *wlan_data; struct wl1271 *wl; struct wl1271_test *wl_test; int ret = 0; /* wl1271 has 2 sdio functions we handle just the wlan part */ if (func->num != 0x02) return -ENODEV; wl_test = kzalloc(sizeof(struct wl1271_test), GFP_KERNEL); if (!wl_test) { dev_err(&func->dev, "Could not allocate memory\n"); return -ENOMEM; } wl = &wl_test->wl; wl->if_priv = func; wl->if_ops = &sdio_ops; /* Grab access to FN0 for ELP reg. */ func->card->quirks |= MMC_QUIRK_LENIENT_FN0; /* Use block mode for transferring over one block size of data */ func->card->quirks |= MMC_QUIRK_BLKSZ_FOR_BYTE_MODE; wlan_data = wl12xx_get_platform_data(); if (IS_ERR(wlan_data)) { ret = PTR_ERR(wlan_data); dev_err(&func->dev, "missing wlan platform data: %d\n", ret); goto out_free; } wl->irq = wlan_data->irq; wl->ref_clock = wlan_data->board_ref_clock; wl->tcxo_clock = wlan_data->board_tcxo_clock; sdio_set_drvdata(func, wl_test); /* power up the device */ ret = wl1271_chip_wakeup(wl); if (ret) { dev_err(&func->dev, "could not wake up chip\n"); goto out_free; } if (wl->fw == NULL) { ret = wl1271_fetch_firmware(wl); if (ret < 0) { dev_err(&func->dev, "firmware fetch error\n"); goto out_off; } } /* fetch NVS */ if (wl->nvs == NULL) { ret = wl1271_fetch_nvs(wl); if (ret < 0) { dev_err(&func->dev, "NVS fetch error\n"); goto out_off; } } ret = wl1271_load_firmware(wl); if (ret < 0) { dev_err(&func->dev, "firmware load error: %d\n", ret); goto out_free; } dev_info(&func->dev, "initialized\n"); /* I/O testing will be done in the tester thread */ wl_test->test_task = kthread_run(tester, wl, "sdio_tester"); if (IS_ERR(wl_test->test_task)) { dev_err(&func->dev, "unable to create kernel thread\n"); ret = PTR_ERR(wl_test->test_task); goto out_free; } return 0; out_off: /* power off the chip */ wl1271_power_off(wl); out_free: kfree(wl_test); return ret; }