static int es705_uart_boot_setup(struct es705_priv *es705)
{
    u8 sbl_sync_cmd = ES705_SBL_SYNC_CMD;
    u8 sbl_boot_cmd = ES705_SBL_BOOT_CMD;
    u32 rspn = sbl_sync_cmd;
    const int match = 1;
    int rc;

    /* Detect BAUD RATE send SBL SYNC BYTE 0x00 */
    dev_dbg(es705->dev, "%s(): write ES705_SBL_SYNC_CMD = 0x%02x\n",
            __func__, sbl_sync_cmd);
    rc = es705_uart_write_then_read(es705, &sbl_sync_cmd, 1,
                                    &rspn, match);
    if (rc < 0) {
        dev_err(es705->dev, "%s(): UART baud rate detection fail\n",
                __func__);
        goto es705_bootup_failed;
    }
    dev_dbg(es705->dev, "%s(): sbl sync ack = 0x%02x\n", __func__, rspn);

    es705->uart_fw_download_rate = 3;
    rc = es705_set_uart_baud_rate(es705);
    if (rc < 0) {
        dev_err(es705->dev, "%s(): uart baud rate set error\n",
                __func__);
        goto es705_bootup_failed;
    }
    es705_set_tty_baud_rate(es705->uart_fw_download_rate);

    /* SBL SYNC BYTE 0x00 */
    dev_dbg(es705->dev, "%s(): write ES705_SBL_SYNC_CMD = 0x%02x\n",
            __func__, sbl_sync_cmd);
    rc = es705_uart_write_then_read(es705, &sbl_sync_cmd, 1,
                                    &rspn, match);
    if (rc < 0) {
        dev_err(es705->dev, "%s(): UART FW Download SBL SYNC fail\n",
                __func__);
        goto es705_bootup_failed;
    }
    dev_dbg(es705->dev, "%s(): sbl sync ack = 0x%02x\n", __func__, rspn);

    /* SBL BOOT BYTE 0x01 */
    dev_dbg(es705->dev, "%s(): write ES705_SBL_BOOT_CMD = 0x%02x\n",
            __func__, sbl_boot_cmd);
    rspn = ES705_SBL_BOOT_ACK;
    rc = es705_uart_write_then_read(es705, &sbl_boot_cmd, 1,
                                    &rspn, match);
    if (rc < 0) {
        dev_err(es705->dev, "%s(): UART FW Download BOOT CMD fail\n",
                __func__);
        goto es705_bootup_failed;
    }
    dev_dbg(es705->dev, "%s(): sbl boot ack = 0x%02x\n", __func__, rspn);
es705_bootup_failed:
    return rc;
}
Example #2
0
static int es705_set_uart_baud_rate(struct es705_priv *es705)
{
	int rc;
	u32 uart_rate_request;
	u32 resp;
	const int match = 1;

	dev_dbg(es705->dev, "%s(): UART baud rate request = 0x%08x\n",
		__func__, es705_uart_baud_rate[es705->uart_fw_download_rate]);

	resp = uart_rate_request =
	    cpu_to_be32(es705_uart_baud_rate[es705->uart_fw_download_rate]);
	rc = es705_uart_write_then_read(es705, &uart_rate_request, 4, &resp,
					match);
	resp = be32_to_cpu(resp);
	if (rc < 0)
		dev_err(es705->dev,
			"%s(): UART baud rate set for FW download FAIL\n",
			__func__);
	else
		dev_dbg(es705->dev, "%s(): UART baud rate resp = 0x%08x\n",
			__func__, resp);

	return rc;
}
Example #3
0
int es705_uart_dev_wdb(struct es705_priv *es705, const void *buf, int len)
{
	/* At this point the command has been determined and is not part
	 * of the data in the buffer. Its just data. Note that we donot
	 * evaluate the contents of the data. It is up to the higher layers
	 * to insure the the codes mode of operation matchs what is being
	 * sent.
	 */
	int ret;
	u32 resp;
	u8 *dptr;

	u32 cmd = ES705_WDB_CMD << 16;

	dev_dbg(es705->dev, "%s(): len = 0x%08x\n", __func__, len);
	dptr = (char *)buf;

	cmd = cmd | (len & 0xFFFF);
	dev_dbg(es705->dev, "%s(): cmd = 0x%08x\n", __func__, cmd);
	cmd = cpu_to_be32(cmd);
	ret = es705_uart_write_then_read(es705, &cmd, sizeof(cmd), &resp, 0);
	if (ret < 0) {
		dev_err(es705->dev, "%s(): cmd write err=%hu\n", __func__, ret);
		goto wdb_err;
	}

	be32_to_cpus(&resp);
	dev_dbg(es705->dev, "%s(): resp = 0x%08x\n", __func__, resp);
	if ((resp & 0xffff0000) != (ES705_WDB_CMD << 16)) {
		dev_err(es705->dev, "%s(): invalid write data block 0x%08x\n",
			__func__, resp);
		goto wdb_err;
	}

	/* The API requires that the subsequent writes are to be
	 * a byte stream (one byte per transport transaction)
	 */
	ret = es705_uart_write(es705, dptr, len);
	if (ret < 0) {
		dev_err(es705->dev, "%s(): wdb error =%d\n", __func__, ret);
		goto wdb_err;
	}

	/* One last ACK read */
	ret = es705_uart_read(es705, &resp, 4);
	if (ret < 0) {
		dev_err(es705->dev, "%s(): last ack %d\n", __func__, ret);
		goto wdb_err;
	}

	if (resp & 0xff000000) {
		dev_err(es705->dev, "%s(): write data block error 0x%0x\n",
			__func__, resp);
		goto wdb_err;
	}

	dev_dbg(es705->dev, "%s(): len = %d\n", __func__, len);

	goto exit;

wdb_err:
	len = -EIO;
exit:
	return len;
}