Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit eecdd971 authored by Girish Mahadevan's avatar Girish Mahadevan
Browse files

serial: msm_geni_serial: Modify the Rx state machine initializations



When opening the port, don't start the Rx state machine as the core clock
related configurations haven't been done at this stage.
During set_termios() operation stop and re-start the Rx state machine
before and after setting up the new baud rate.
When stopping the state machine, always try to issue a cancel on the Rx
state machine before attempting to abort the state machine and if an abort
is needed, ensure that the pad outputs are also set to the default.

Change-Id: I29466d14783dc2ccacaf532baa16a0900dfe0f70
Signed-off-by: default avatarGirish Mahadevan <girishm@codeaurora.org>
parent cd538dbf
Loading
Loading
Loading
Loading
+30 −8
Original line number Diff line number Diff line
@@ -184,6 +184,7 @@ static int msm_geni_serial_power_on(struct uart_port *uport);
static void msm_geni_serial_power_off(struct uart_port *uport);
static int msm_geni_serial_poll_bit(struct uart_port *uport,
				int offset, int bit_field, bool set);
static void msm_geni_serial_stop_rx(struct uart_port *uport);

static atomic_t uart_line_id = ATOMIC_INIT(0);

@@ -541,6 +542,7 @@ static void msm_geni_serial_abort_rx(struct uart_port *uport)
	msm_geni_serial_poll_bit(uport, SE_GENI_S_CMD_CTRL_REG,
					S_GENI_CMD_ABORT, false);
	geni_write_reg_nolog(irq_clear, uport->membase, SE_GENI_S_IRQ_CLEAR);
	geni_write_reg(FORCE_DEFAULT, uport->membase, GENI_FORCE_DEFAULT_REG);
}

#ifdef CONFIG_CONSOLE_POLL
@@ -916,7 +918,8 @@ static void msm_geni_serial_start_rx(struct uart_port *uport)

	geni_status = geni_read_reg_nolog(uport->membase, SE_GENI_STATUS);
	if (geni_status & S_GENI_CMD_ACTIVE)
		msm_geni_serial_abort_rx(uport);
		msm_geni_serial_stop_rx(uport);

	geni_setup_s_cmd(uport->membase, UART_START_READ, 0);

	if (port->xfer_mode == FIFO_MODE) {
@@ -938,7 +941,7 @@ static void msm_geni_serial_start_rx(struct uart_port *uport)
		if (ret) {
			dev_err(uport->dev, "%s: RX Prep dma failed %d\n",
				__func__, ret);
			msm_geni_serial_abort_rx(uport);
			msm_geni_serial_stop_rx(uport);
			return;
		}
	}
@@ -976,6 +979,7 @@ static void msm_geni_serial_stop_rx(struct uart_port *uport)
	unsigned int geni_m_irq_en;
	unsigned int geni_status;
	struct msm_geni_serial_port *port = GET_DEV_PORT(uport);
	u32 irq_clear = S_CMD_DONE_EN;

	if (!uart_console(uport) && pm_runtime_status_suspended(uport->dev)) {
		dev_err(uport->dev, "%s.Device is suspended.\n", __func__);
@@ -1007,6 +1011,16 @@ static void msm_geni_serial_stop_rx(struct uart_port *uport)
	/* Possible stop rx is called multiple times. */
	if (!(geni_status & S_GENI_CMD_ACTIVE))
		return;
	geni_cancel_s_cmd(uport->membase);
	/*
	 * Ensure that the cancel goes through before polling for the
	 * cancel control bit.
	 */
	mb();
	msm_geni_serial_poll_bit(uport, SE_GENI_S_CMD_CTRL_REG,
					S_GENI_CMD_CANCEL, false);
	geni_write_reg_nolog(irq_clear, uport->membase, SE_GENI_S_IRQ_CLEAR);
	if ((geni_status & S_GENI_CMD_ACTIVE))
		msm_geni_serial_abort_rx(uport);
}

@@ -1588,7 +1602,6 @@ static int msm_geni_serial_startup(struct uart_port *uport)
			goto exit_startup;
	}

	msm_geni_serial_start_rx(uport);
	/*
	 * Ensure that all the port configuration writes complete
	 * before returning to the framework.
@@ -1709,11 +1722,17 @@ static void msm_geni_serial_set_termios(struct uart_port *uport,
	struct msm_geni_serial_port *port = GET_DEV_PORT(uport);
	unsigned long clk_rate;

	if (!uart_console(uport) && pm_runtime_status_suspended(uport->dev)) {
		IPC_LOG_MSG(port->ipc_log_pwr,
			"%s Device suspended,vote clocks on.\n", __func__);
	if (!uart_console(uport)) {
		int ret = msm_geni_serial_power_on(uport);

		if (ret) {
			IPC_LOG_MSG(port->ipc_log_misc,
				"%s: Failed to vote clock on:%d\n",
							__func__, ret);
			return;
		}
	}
	msm_geni_serial_stop_rx(uport);
	/* baud rate */
	baud = uart_get_baud_rate(uport, termios, old, 300, 4000000);
	port->cur_baud = baud;
@@ -1802,6 +1821,9 @@ static void msm_geni_serial_set_termios(struct uart_port *uport,
	IPC_LOG_MSG(port->ipc_log_misc, "BitsChar%d stop bit%d\n",
				bits_per_char, stop_bit_len);
exit_set_termios:
	msm_geni_serial_start_rx(uport);
	if (!uart_console(uport))
		msm_geni_serial_power_off(uport);
	return;

}