Esempio n. 1
0
int wl1271_boot(struct wl1271 *wl)
{
	int ret;

	/* polarity must be set before the firmware is loaded */
	ret = wl1271_boot_write_irq_polarity(wl);
	if (ret < 0)
		goto out;

	/* upload NVS and firmware */
	ret = wl1271_load_firmware(wl);
	if (ret)
		return ret;

	/* 10.5 start firmware */
	ret = wl1271_boot_run_firmware(wl);
	if (ret < 0)
		goto out;

	ret = wl1271_write32(wl, ACX_REG_INTERRUPT_MASK,
			     WL1271_ACX_ALL_EVENTS_VECTOR);
	if (ret < 0)
		goto out;

	/* Enable firmware interrupts now */
	ret = wl1271_boot_enable_interrupts(wl);
	if (ret < 0)
		goto out;

	ret = wl1271_event_mbox_config(wl);

out:
	return ret;
}
Esempio n. 2
0
static int wl1271_boot_run_firmware(struct wl1271 *wl)
{
    int loop, ret;
    u32 chip_id, interrupt;

    wl1271_boot_set_ecpu_ctrl(wl, ECPU_CONTROL_HALT);

    chip_id = wl1271_reg_read32(wl, CHIP_ID_B);

    wl1271_debug(DEBUG_BOOT, "chip id after firmware boot: 0x%x", chip_id);

    if (chip_id != wl->chip.id) {
        wl1271_error("chip id doesn't match after firmware boot");
        return -EIO;
    }

    /* wait for init to complete */
    loop = 0;
    while (loop++ < INIT_LOOP) {
        udelay(INIT_LOOP_DELAY);
        interrupt = wl1271_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR);

        if (interrupt == 0xffffffff) {
            wl1271_error("error reading hardware complete "
                         "init indication");
            return -EIO;
        }
        /* check that ACX_INTR_INIT_COMPLETE is enabled */
        else if (interrupt & WL1271_ACX_INTR_INIT_COMPLETE) {
            wl1271_reg_write32(wl, ACX_REG_INTERRUPT_ACK,
                               WL1271_ACX_INTR_INIT_COMPLETE);
            break;
        }
    }

    if (loop >= INIT_LOOP) {
        wl1271_error("timeout waiting for the hardware to "
                     "complete initialization");
        return -EIO;
    }

    /* get hardware config command mail box */
    wl->cmd_box_addr = wl1271_reg_read32(wl, REG_COMMAND_MAILBOX_PTR);

    /* get hardware config event mail box */
    wl->event_box_addr = wl1271_reg_read32(wl, REG_EVENT_MAILBOX_PTR);

    /* set the working partition to its "running" mode offset */
    wl1271_set_partition(wl,
                         part_table[PART_WORK].mem.start,
                         part_table[PART_WORK].mem.size,
                         part_table[PART_WORK].reg.start,
                         part_table[PART_WORK].reg.size);

    wl1271_debug(DEBUG_MAILBOX, "cmd_box_addr 0x%x event_box_addr 0x%x",
                 wl->cmd_box_addr, wl->event_box_addr);

    wl1271_boot_fw_version(wl);

    /*
     * in case of full asynchronous mode the firmware event must be
     * ready to receive event from the command mailbox
     */

    /* enable gpio interrupts */
    wl1271_boot_enable_interrupts(wl);

    /* unmask all mbox events  */
    wl->event_mask = 0xffffffff;

    ret = wl1271_event_unmask(wl);
    if (ret < 0) {
        wl1271_error("EVENT mask setting failed");
        return ret;
    }

    wl1271_event_mbox_config(wl);

    /* firmware startup completed */
    return 0;
}
Esempio n. 3
0
int wl1271_boot(struct wl1271 *wl)
{
	int ret = 0;
	u32 tmp, clk, pause;

	if (REF_CLOCK == 0 || REF_CLOCK == 2 || REF_CLOCK == 4)
		/* ref clk: 19.2/38.4/38.4-XTAL */
		clk = 0x3;
	else if (REF_CLOCK == 1 || REF_CLOCK == 3)
		/* ref clk: 26/52 */
		clk = 0x5;

	if (REF_CLOCK != 0) {
		u16 val;
		/* Set clock type */
		val = wl1271_top_reg_read(wl, OCP_REG_CLK_TYPE);
		val &= FREF_CLK_TYPE_BITS;
		val |= CLK_REQ_PRCM;
		wl1271_top_reg_write(wl, OCP_REG_CLK_TYPE, val);
	} else {
		u16 val;
		/* Set clock polarity */
		val = wl1271_top_reg_read(wl, OCP_REG_CLK_POLARITY);
		val &= FREF_CLK_POLARITY_BITS;
		val |= CLK_REQ_OUTN_SEL;
		wl1271_top_reg_write(wl, OCP_REG_CLK_POLARITY, val);
	}

	wl1271_spi_write32(wl, PLL_PARAMETERS, clk);

	pause = wl1271_spi_read32(wl, PLL_PARAMETERS);

	wl1271_debug(DEBUG_BOOT, "pause1 0x%x", pause);

	pause &= ~(WU_COUNTER_PAUSE_VAL); /* FIXME: This should probably be
					   * WU_COUNTER_PAUSE_VAL instead of
					   * 0x3ff (magic number ).  How does
					   * this work?! */
	pause |= WU_COUNTER_PAUSE_VAL;
	wl1271_spi_write32(wl, WU_COUNTER_PAUSE, pause);

	/* Continue the ELP wake up sequence */
	wl1271_spi_write32(wl, WELP_ARM_COMMAND, WELP_ARM_COMMAND_VAL);
	udelay(500);

	wl1271_set_partition(wl, &part_table[PART_DRPW]);

	/* Read-modify-write DRPW_SCRATCH_START register (see next state)
	   to be used by DRPw FW. The RTRIM value will be added by the FW
	   before taking DRPw out of reset */

	wl1271_debug(DEBUG_BOOT, "DRPW_SCRATCH_START %08x", DRPW_SCRATCH_START);
	clk = wl1271_spi_read32(wl, DRPW_SCRATCH_START);

	wl1271_debug(DEBUG_BOOT, "clk2 0x%x", clk);

	/* 2 */
	clk |= (REF_CLOCK << 1) << 4;
	wl1271_spi_write32(wl, DRPW_SCRATCH_START, clk);

	wl1271_set_partition(wl, &part_table[PART_WORK]);

	/* Disable interrupts */
	wl1271_spi_write32(wl, ACX_REG_INTERRUPT_MASK, WL1271_ACX_INTR_ALL);

	ret = wl1271_boot_soft_reset(wl);
	if (ret < 0)
		goto out;

	/* 2. start processing NVS file */
	ret = wl1271_boot_upload_nvs(wl);
	if (ret < 0)
		goto out;

	/* write firmware's last address (ie. it's length) to
	 * ACX_EEPROMLESS_IND_REG */
	wl1271_debug(DEBUG_BOOT, "ACX_EEPROMLESS_IND_REG");

	wl1271_spi_write32(wl, ACX_EEPROMLESS_IND_REG,
			   ACX_EEPROMLESS_IND_REG);

	tmp = wl1271_spi_read32(wl, CHIP_ID_B);

	wl1271_debug(DEBUG_BOOT, "chip id 0x%x", tmp);

	/* 6. read the EEPROM parameters */
	tmp = wl1271_spi_read32(wl, SCR_PAD2);

	ret = wl1271_boot_write_irq_polarity(wl);
	if (ret < 0)
		goto out;

	/* FIXME: Need to check whether this is really what we want */
	wl1271_spi_write32(wl, ACX_REG_INTERRUPT_MASK,
			   WL1271_ACX_ALL_EVENTS_VECTOR);

	/* WL1271: The reference driver skips steps 7 to 10 (jumps directly
	 * to upload_fw) */

	ret = wl1271_boot_upload_firmware(wl);
	if (ret < 0)
		goto out;

	/* 10.5 start firmware */
	ret = wl1271_boot_run_firmware(wl);
	if (ret < 0)
		goto out;

	/* Enable firmware interrupts now */
	wl1271_boot_enable_interrupts(wl);

	/* set the wl1271 default filters */
	wl->rx_config = WL1271_DEFAULT_RX_CONFIG;
	wl->rx_filter = WL1271_DEFAULT_RX_FILTER;

	wl1271_event_mbox_config(wl);

out:
	return ret;
}