int es705_uart_es705_wakeup(struct es705_priv *es705)
{
    int rc;
    char wakeup_char = 'A';

    dev_info(es705_priv.dev, "%s(): ********* START UART wakeup\n", __func__);

    rc = es705_uart_open(es705);
    if (rc) {
        dev_err(es705->dev, "%s(): uart open error\n",
                __func__);
        goto es705_uart_es705_wakeup_exit;
    }

    /* eS705 wakeup. Write wakeup character to UART */
    rc = es705_uart_write(es705, &wakeup_char, sizeof(wakeup_char));
    if (rc < 0)
        dev_err(es705->dev, "%s(): wakeup via uart FAIL\n",
                __func__);
    es705_uart_close(es705);
es705_uart_es705_wakeup_exit:
    dev_info(es705_priv.dev, "%s(): ********* END UART wakeup\n", __func__);

    return rc;
}
static int es705_uart_probe_thread(void *ptr)
{
    int rc = 0;
    struct device *dev = (struct device *) ptr;

    rc = es705_uart_open(&es705_priv);
    if (rc) {
        dev_err(dev, "%s(): es705_uart_open() failed %d\n",
                __func__, rc);
        return rc;
    }

    /* set es705 function pointers */
    es705_priv.dev_read = es705_uart_read;
    es705_priv.dev_write = es705_uart_write;
    es705_priv.cmd = es705_uart_cmd;
    es705_priv.boot_setup = es705_uart_boot_setup;
    es705_priv.boot_finish = es705_uart_boot_finish;

    es705_priv.streamdev = uart_streamdev;

    rc = es705_core_probe(dev);
    if (rc) {
        dev_err(dev, "%s(): es705_core_probe() failed %d\n",
                __func__, rc);
        goto bootup_error;
    }

    rc = es705_bootup(&es705_priv);

    if (rc) {
        dev_err(dev, "%s(): es705_bootup failed %d\n",
                __func__, rc);
        goto bootup_error;
    }

    rc = snd_soc_register_codec(dev, &soc_codec_dev_es705,
                                es705_dai, ES705_NUM_CODEC_DAIS);
    dev_dbg(dev, "%s(): rc = snd_soc_regsiter_codec() = %d\n",
            __func__, rc);

    /* init es705 character device here, now that the UART is discovered */
    rc = es705_init_cdev(&es705_priv);
    if (rc) {
        dev_err(dev, "%s(): failed to initialize char device = %d\n",
                __func__, rc);
        goto cdev_init_error;
    }

    return rc;

bootup_error:
    /* close filp */
    es705_uart_close(&es705_priv);
cdev_init_error:
    dev_dbg(es705_priv.dev, "%s(): exit with error\n", __func__);
    return rc;
}
示例#3
0
static int es705_uart_probe_thread(void *ptr)
{
	int rc = 0;
	struct device *dev = (struct device *)ptr;

	if (variant_aif_required == NO_AIF)
		return rc;

	rc = es705_uart_open(&es705_priv);
	if (rc) {
		dev_err(dev, "%s(): es705_uart_open() failed %d\n", __func__,
			rc);
		return rc;
	}

	/* set es705 function pointers */
	es705_priv.dev_read = es705_uart_read;
	es705_priv.dev_write = es705_uart_write;
	es705_priv.cmd = es705_uart_cmd;
	es705_priv.boot_setup = es705_uart_boot_setup;
	es705_priv.boot_finish = es705_uart_boot_finish;

	es705_priv.streamdev = uart_streamdev;
	es705_priv.datablockdev = uart_datablockdev;

	rc = es705_core_init(dev);
	if (rc) {
		dev_err(dev, "%s(): es705_core_init() failed %d\n", __func__,
			rc);
		goto bootup_error;
	}

	rc = es705_bootup(&es705_priv);

	if (rc) {
		dev_err(dev, "%s(): es705_bootup failed %d\n", __func__, rc);
		goto bootup_error;
	}

	/* init es705 character device here, now that the UART is discovered */
	rc = es705_init_cdev(&es705_priv);
	if (rc) {
		dev_err(dev, "%s(): failed to initialize char device = %d\n",
			__func__, rc);
		goto cdev_init_error;
	}

	return rc;

bootup_error:
	/* close filp */
	es705_uart_close(&es705_priv);
cdev_init_error:
	dev_dbg(es705_priv.dev, "%s(): exit with error\n", __func__);
	return rc;
}
示例#4
0
int es705_uart_fw_download(struct es705_priv *es705, int fw_type)
{
	int rc;

	dev_info(es705_priv.dev, "%s(): ********* START %s FW Download\n",
				__func__, fw_type == VOICESENSE ? "VS" : "Standard");

	rc = es705_uart_open(es705);
	if (rc) {
		dev_err(es705->dev, "%s(): uart open error\n",
			__func__);
		goto uart_open_error;
	}
	es705_set_tty_baud_rate(UART_DOWNLOAD_INITIAL_SYNC_BAUD_RATE_INDEX);

	rc = es705_uart_boot_setup(es705);
	if (rc < 0) {
		dev_err(es705->dev, "%s(): uart boot setup error\n",
			__func__);
		goto uart_download_error;
	}

	if (fw_type == VOICESENSE)
		rc = es705_uart_write(es705, (char *)es705->vs->data,
				es705->vs->size);
	else
		rc = es705_uart_write(es705, (char *)es705->standard->data,
				es705->standard->size);
	if (rc < 0) {
		dev_err(es705->dev, "%s(): uart %s image write fail\n",
			__func__, fw_type == VOICESENSE ? "vs" : "standard");
		rc = -EIO;
		goto uart_download_error;
	}

	dev_info(es705->dev, "%s(): %s fw download done\n",
		__func__, fw_type == VOICESENSE ? "vs" : "standard");

	rc = es705_uart_boot_finish(es705);
	if (rc < 0)
		dev_err(es705->dev, "%s(): uart boot finish error\n",
			__func__);

uart_download_error:
	es705_uart_close(es705);
uart_open_error:

	dev_info(es705_priv.dev, "%s(): ********* END %s FW Download\n",
				__func__, fw_type == VOICESENSE ? "VS" : "Standard");

	return rc;
}
示例#5
0
int es705_uart_open(struct es705_priv *es705)
{
	long err = 0;
	struct file *fp = NULL;
	unsigned long timeout = jiffies + msecs_to_jiffies(250);
	int attempt = 0;

	dev_dbg(es705->dev, "%s(): start open tty\n",
		  __func__);

	if (es705->uart_state == UART_OPEN)
		es705_uart_close(es705);

	/* SAMSUNG - uart_gpio control */
	if (es705->pdata->uart_gpio != -1)
		gpio_set_value(es705->pdata->uart_gpio, 1);

	/* try to probe tty node every 50 ms for 250 ms */
	do {
		if (attempt > 0)
			msleep(50);
		dev_dbg(es705->dev,
			"%s(): probing for tty on %s (attempt %d)\n",
			 __func__, UART_TTY_DEVICE_NODE, ++attempt);

		fp = filp_open(UART_TTY_DEVICE_NODE,
			       O_RDWR | O_NONBLOCK | O_NOCTTY,
			       0);
		err = PTR_ERR(fp);
	} while (time_before(jiffies, timeout) && err == -ENOENT);

	if (IS_ERR_OR_NULL(fp)) {
		dev_err(es705->dev,
			"%s(): UART device node open failed\n", __func__);
		return -ENODEV;
	}

	/* device node found */
	dev_dbg(es705->dev, "%s(): successfully opened tty\n",
		  __func__);

	/* set uart_dev members */
	es705_priv.uart_dev.file = fp;
	es705_priv.uart_dev.tty =
		((struct tty_file_private *)fp->private_data)->tty;

	/* set baudrate to FW baud (common case) */
	es705_set_tty_baud_rate(es705->uart_fw_download_rate);
	es705->uart_state = UART_OPEN;
	return 0;
}
static int es705_uart_remove(struct platform_device *dev)
{
    int rc = 0;

    if (es705_priv.uart_dev.file)
        es705_uart_close(&es705_priv);

    es705_priv.uart_dev.tty = NULL;
    es705_priv.uart_dev.file = NULL;

    snd_soc_unregister_codec(es705_priv.dev);

    return rc;
}
static int es705_slim_vs_streaming(struct es705_priv *es705)
{
	int rc;
#ifdef VS_BUFFER_VIA_UART
/*
	rc = gpio_direction_input(es705->pdata->wakeup_gpio);
	if (rc < 0) {
		dev_err(es705_priv.dev, "%s(): set GPIO for UART failed",
			__func__);
		goto es705_vs_streaming_error;
	}
*/
	rc = es705_uart_open(es705);
	if (rc) {
		dev_err(es705->dev, "%s(): uart open error\n",
			__func__);
		goto es705_vs_streaming_error;
	}
	/* set speed to bootloader baud */
	es705_configure_tty(es705_priv.uart_dev.tty,
		UART_TTY_BAUD_RATE_BOOTLOADER, UART_TTY_STOP_BITS);
	/* wait until all data will be read by App */
/*
	rc = es705_uart_write(es705, data, sz);
	if (rc != sz) {
		dev_err(es705->dev, "%s(): uart write fail\n",
			__func__);
		rc = -EIO;
		goto es705_vs_streaming_error;
	}
	msleep(20000);
*/
	rc = es705_uart_close(es705);
	if (rc) {
		dev_err(es705->dev, "%s(): uart close error\n",
			__func__);
		goto es705_vs_streaming_error;
	}
/*
	rc = gpio_direction_output(es705->pdata->wakeup_gpio, 0);
	if (rc < 0)
		dev_err(es705_priv.dev, "%s(): set UART direction failed",
			__func__);
	}
*/
#else
	/*
	 * VS BUFFER via SLIMBus
	 * end point is
	 * 156 - 0x9c for pass through 1 chan mode
	 * 156 - 0x9c and 157 - 0x9d for pass through 2 channels mode
	 */
	u32 vs_stream_end_point = 0x8028809C;
	u32 rspn = vs_stream_end_point;
	int match = 1;
	u32 vs_stream_cmd = 0x90250202 | ES705_STREAM_ENABLE;

	/* select streaming pathID */
	dev_dbg(es705->dev, "%s(): Set VS Streaming PathID\n", __func__);
	rc = es705_slim_write_then_read(es705, &vs_stream_end_point,
			      sizeof(vs_stream_end_point), &rspn, match);
	if (rc) {
		dev_err(es705->dev, "%s(): Select VS stream Path ID Fail\n",
			__func__);
		goto es705_vs_streaming_error;
	}

	/* enable streaming */
	dev_dbg(es705->dev, "%s(): Enable VS Streaming\n", __func__);
	rc = es705_slim_write(es705, &vs_stream_cmd, 4);
	if (rc) {
		dev_err(es705->dev, "%s(): Enable VS streaming Fail\n",
			__func__);
		goto es705_vs_streaming_error;
	}

	/* TODO wait end of streaming and disable */
/*
	vs_stream = 0x90250200 | ES705_STREAM_DISABLE;
	rc = es705_slim_write(es705, &vs_stream_cmd, 4);
	if (rc)
		dev_err(es705->dev, "%s(): Disable VS streaming Fail\n",
			__func__);
*/
#endif
es705_vs_streaming_error:
	return rc;
}