Ejemplo n.º 1
0
static int es705_uart_boot_finish(struct es705_priv *es705)
{
	u32 sync_cmd;
	u32 sync_resp;
	char msg[4];
	int rc, retry = 3;

	/*
	 * Give the chip some time to become ready after firmware
	 * download. (FW is still transferring)
	 */
	msleep(50);

	/*
	 * Read 4 bytes of VS FW download status
	 * TODO To avoid possible problem in the future
	 * if FW goes to send less or more then 4 bytes
	 * Need modify code to read UART until read
	 * buffer is empty
	 */
	rc = es705_uart_read(es705, msg, 4);
	if (rc < 0)
		dev_err(es705->dev, "%s(): UART read fail\n", __func__);
	else
		dev_dbg(es705->dev, "%s(): read byte = 0x%02x%02x%02x%02x\n",
			__func__, msg[0], msg[1], msg[2], msg[3]);

	if (es705->es705_power_state == ES705_SET_POWER_STATE_VS_OVERLAY) {
		sync_cmd = (ES705_SYNC_CMD << 16) | ES705_SYNC_INTR_RISING_EDGE;
		dev_info(es705->dev, "%s(): FW type : VOICESENSE\n", __func__);
	} else {
		sync_cmd = (ES705_SYNC_CMD << 16) | ES705_SYNC_POLLING;
		dev_info(es705->dev, "%s(): FW type : STANDARD\n", __func__);
	}

	dev_dbg(es705->dev, "%s(): write ES705_SYNC_CMD = 0x%08x\n", __func__,
		sync_cmd);

es705_boot_retry:
	rc = es705_uart_cmd(es705, sync_cmd, 0, &sync_resp);
	if (rc < 0) {
		dev_err(es705->dev,
			"%s(): firmware load failed (no sync response)\n",
			__func__);
		goto es705_boot_finish_failed;
	}
	if (sync_cmd != sync_resp) {
		dev_err(es705->dev,
			"%s(): firmware load failed, invalid sync response 0x%08x\n",
			__func__, sync_resp);
		if (--retry) {
			dev_info(es705->dev, "%s(): buffer flush & retry\n",
				 __func__);
			tty_perform_flush(es705->uart_dev.tty, TCIFLUSH);
			goto es705_boot_retry;
		}
		rc = -EIO;
		goto es705_boot_finish_failed;
	}

	dev_dbg(es705->dev, "%s(): firmware load success 0x%08x\n", __func__,
		sync_resp);

es705_boot_finish_failed:
	return rc;
}
Ejemplo n.º 2
0
static int ipw_ioctl(struct tty_struct *linux_tty, struct file *file,
		     unsigned int cmd, unsigned long arg)
{
	struct ipw_tty *tty = linux_tty->driver_data;

	if (!tty)
		return -ENODEV;

	if (!atomic_read(&tty->open_count))
		return -EINVAL;

	/* FIXME: Exactly how is the tty object locked here .. */

	switch (cmd) {
	case TIOCGSERIAL:
		return ipwireless_get_serial_info(tty, (void __user *) arg);

	case TIOCSSERIAL:
		return 0;	/* Keeps the PCMCIA scripts happy. */
	}

	if (tty->tty_type == TTYTYPE_MODEM) {
		switch (cmd) {
		case PPPIOCGCHAN:
			{
				int chan = ipwireless_ppp_channel_index(
							tty->network);

				if (chan < 0)
					return -ENODEV;
				if (put_user(chan, (int __user *) arg))
					return -EFAULT;
			}
			return 0;

		case PPPIOCGUNIT:
			{
				int unit = ipwireless_ppp_unit_number(
						tty->network);

				if (unit < 0)
					return -ENODEV;
				if (put_user(unit, (int __user *) arg))
					return -EFAULT;
			}
			return 0;

		case FIONREAD:
			{
				int val = 0;

				if (put_user(val, (int __user *) arg))
					return -EFAULT;
			}
			return 0;
		case TCFLSH:
			return tty_perform_flush(linux_tty, arg);
		}
	}
	return tty_mode_ioctl(linux_tty, file, cmd , arg);
}
Ejemplo n.º 3
0
static int send_prio_char(struct tty_struct *tty, char ch)
{
	int	was_stopped = tty->stopped;

#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
	if (tty->ops->send_xchar) {
		tty->ops->send_xchar(tty, ch);
#else
	if (tty->driver->send_xchar) {
		tty->driver->send_xchar(tty, ch);
#endif
		return 0;
	}

	if (tty_write_lock(tty, 0) < 0)
		return -ERESTARTSYS;

	if (was_stopped)
		start_tty(tty);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
	tty->ops->write(tty, &ch, 1);
#else
	tty->driver->write(tty, &ch, 1);
#endif
	if (was_stopped)
		stop_tty(tty);
	tty_write_unlock(tty);
	return 0;
}

int n_tty_ioctl_helper(struct tty_struct *tty, struct file *file,
		       unsigned int cmd, unsigned long arg)
{
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
	unsigned long flags;
#endif
	int retval;

	switch (cmd) {
	case TCXONC:
		retval = tty_check_change(tty);
		if (retval)
			return retval;
		switch (arg) {
		case TCOOFF:
			if (!tty->flow_stopped) {
				tty->flow_stopped = 1;
				stop_tty(tty);
			}
			break;
		case TCOON:
			if (tty->flow_stopped) {
				tty->flow_stopped = 0;
				start_tty(tty);
			}
			break;
		case TCIOFF:
			if (STOP_CHAR(tty) != __DISABLED_CHAR)
				return send_prio_char(tty, STOP_CHAR(tty));
			break;
		case TCION:
			if (START_CHAR(tty) != __DISABLED_CHAR)
				return send_prio_char(tty, START_CHAR(tty));
			break;
		default:
			return -EINVAL;
		}
		return 0;
	case TCFLSH:
		return tty_perform_flush(tty, arg);
	case TIOCPKT:
	{
		int pktmode;

		if (tty->driver->type != TTY_DRIVER_TYPE_PTY ||
		    tty->driver->subtype != PTY_TYPE_MASTER)
			return -ENOTTY;
		if (get_user(pktmode, (int __user *) arg))
			return -EFAULT;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
		spin_lock_irqsave(&tty->ctrl_lock, flags);
#endif
		if (pktmode) {
			if (!tty->packet) {
				tty->packet = 1;
				tty->link->ctrl_status = 0;
			}
		} else
			tty->packet = 0;
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,26))
		spin_unlock_irqrestore(&tty->ctrl_lock, flags);
#endif
		return 0;
	}
	default:
		/* Try the mode commands */
		return tty_mode_ioctl(tty, file, cmd, arg);
	}
}