/* * Start of Alphascale asm9260 defines * This list contains only differences of existing bits * between imx2x and asm9260
*/ #define ASM9260_HW_CTRL0 0x0000 /* * RW. Tell the UART to execute the RX DMA Command. The * UART will clear this bit at the end of receive execution.
*/ #define ASM9260_BM_CTRL0_RXDMA_RUN BIT(28) /* RW. 0 use FIFO for status register; 1 use DMA */ #define ASM9260_BM_CTRL0_RXTO_SOURCE_STATUS BIT(25) /* * RW. RX TIMEOUT Enable. Valid for FIFO and DMA. * Warning: If this bit is set to 0, the RX timeout will not affect receive DMA * operation. If this bit is set to 1, a receive timeout will cause the receive * DMA logic to terminate by filling the remaining DMA bytes with garbage data.
*/ #define ASM9260_BM_CTRL0_RXTO_ENABLE BIT(24) /* * RW. Receive Timeout Counter Value: number of 8-bit-time to wait before * asserting timeout on the RX input. If the RXFIFO is not empty and the RX * input is idle, then the watchdog counter will decrement each bit-time. Note * 7-bit-time is added to the programmed value, so a value of zero will set * the counter to 7-bit-time, a value of 0x1 gives 15-bit-time and so on. Also * note that the counter is reloaded at the end of each frame, so if the frame * is 10 bits long and the timeout counter value is zero, then timeout will * occur (when FIFO is not empty) even if the RX input is not idle. The default * value is 0x3 (31 bit-time).
*/ #define ASM9260_BM_CTRL0_RXTO_MASK (0xff << 16) /* TIMEOUT = (100*7+1)*(1/BAUD) */ #define ASM9260_BM_CTRL0_DEFAULT_RXTIMEOUT (20 << 16)
/* TX ctrl register */ #define ASM9260_HW_CTRL1 0x0010 /* * RW. Tell the UART to execute the TX DMA Command. The * UART will clear this bit at the end of transmit execution.
*/ #define ASM9260_BM_CTRL1_TXDMA_RUN BIT(28)
#define ASM9260_HW_CTRL2 0x0020 /* * RW. Receive Interrupt FIFO Level Select. * The trigger points for the receive interrupt are as follows: * ONE_EIGHTHS = 0x0 Trigger on FIFO full to at least 2 of 16 entries. * ONE_QUARTER = 0x1 Trigger on FIFO full to at least 4 of 16 entries. * ONE_HALF = 0x2 Trigger on FIFO full to at least 8 of 16 entries. * THREE_QUARTERS = 0x3 Trigger on FIFO full to at least 12 of 16 entries. * SEVEN_EIGHTHS = 0x4 Trigger on FIFO full to at least 14 of 16 entries.
*/ #define ASM9260_BM_CTRL2_RXIFLSEL (7 << 20) #define ASM9260_BM_CTRL2_DEFAULT_RXIFLSEL (3 << 20) /* RW. Same as RXIFLSEL */ #define ASM9260_BM_CTRL2_TXIFLSEL (7 << 16) #define ASM9260_BM_CTRL2_DEFAULT_TXIFLSEL (2 << 16) /* RW. Set DTR. When this bit is 1, the output is 0. */ #define ASM9260_BM_CTRL2_DTR BIT(10) /* RW. Loop Back Enable */ #define ASM9260_BM_CTRL2_LBE BIT(7) #define ASM9260_BM_CTRL2_PORT_ENABLE BIT(0)
#define ASM9260_HW_LINECTRL 0x0030 /* * RW. Stick Parity Select. When bits 1, 2, and 7 of this register are set, the * parity bit is transmitted and checked as a 0. When bits 1 and 7 are set, * and bit 2 is 0, the parity bit is transmitted and checked as a 1. When this * bit is cleared stick parity is disabled.
*/ #define ASM9260_BM_LCTRL_SPS BIT(7) /* RW. Word length */ #define ASM9260_BM_LCTRL_WLEN (3 << 5) #define ASM9260_BM_LCTRL_CHRL_5 (0 << 5) #define ASM9260_BM_LCTRL_CHRL_6 (1 << 5) #define ASM9260_BM_LCTRL_CHRL_7 (2 << 5) #define ASM9260_BM_LCTRL_CHRL_8 (3 << 5)
/* * RW. In DMA mode, up to 4 Received/Transmit characters can be accessed at a * time. In PIO mode, only one character can be accessed at a time. The status * register contains the receive data flags and valid bits.
*/ #define ASM9260_HW_DATA 0x0050
#define ASM9260_HW_STAT 0x0060 /* RO. If 1, UARTAPP is present in this product. */ #define ASM9260_BM_STAT_PRESENT BIT(31) /* RO. If 1, HISPEED is present in this product. */ #define ASM9260_BM_STAT_HISPEED BIT(30) /* RO. Receive FIFO Full. */ #define ASM9260_BM_STAT_RXFULL BIT(26)
/* RO. The UART Debug Register contains the state of the DMA signals. */ #define ASM9260_HW_DEBUG 0x0070 /* DMA Command Run Status */ #define ASM9260_BM_DEBUG_TXDMARUN BIT(5) #define ASM9260_BM_DEBUG_RXDMARUN BIT(4) /* DMA Command End Status */ #define ASM9260_BM_DEBUG_TXCMDEND BIT(3) #define ASM9260_BM_DEBUG_RXCMDEND BIT(2) /* DMA Request Status */ #define ASM9260_BM_DEBUG_TXDMARQ BIT(1) #define ASM9260_BM_DEBUG_RXDMARQ BIT(0)
#define ASM9260_HW_ILPR 0x0080
#define ASM9260_HW_RS485CTRL 0x0090 /* * RW. This bit reverses the polarity of the direction control signal on the RTS * (or DTR) pin. * If 0, The direction control pin will be driven to logic ‘0’ when the * transmitter has data to be sent. It will be driven to logic ‘1’ after the * last bit of data has been transmitted.
*/ #define ASM9260_BM_RS485CTRL_ONIV BIT(5) /* RW. Enable Auto Direction Control. */ #define ASM9260_BM_RS485CTRL_DIR_CTRL BIT(4) /* * RW. If 0 and DIR_CTRL = 1, pin RTS is used for direction control. * If 1 and DIR_CTRL = 1, pin DTR is used for direction control.
*/ #define ASM9260_BM_RS485CTRL_PINSEL BIT(3) /* RW. Enable Auto Address Detect (AAD). */ #define ASM9260_BM_RS485CTRL_AADEN BIT(2) /* RW. Disable receiver. */ #define ASM9260_BM_RS485CTRL_RXDIS BIT(1) /* RW. Enable RS-485/EIA-485 Normal Multidrop Mode (NMM) */ #define ASM9260_BM_RS485CTRL_RS485EN BIT(0)
#define ASM9260_HW_RS485ADRMATCH 0x00a0 /* Contains the address match value. */ #define ASM9260_BM_RS485ADRMATCH_MASK (0xff << 0)
#define ASM9260_HW_RS485DLY 0x00b0 /* * RW. Contains the direction control (RTS or DTR) delay value. This delay time * is in periods of the baud clock.
*/ #define ASM9260_BM_RS485DLY_MASK (0xff << 0)
#define ASM9260_HW_AUTOBAUD 0x00c0 /* WO. Auto-baud time-out interrupt clear bit. */ #define ASM9260_BM_AUTOBAUD_TO_INT_CLR BIT(9) /* WO. End of auto-baud interrupt clear bit. */ #define ASM9260_BM_AUTOBAUD_EO_INT_CLR BIT(8) /* Restart in case of timeout (counter restarts at next UART Rx falling edge) */ #define ASM9260_BM_AUTOBAUD_AUTORESTART BIT(2) /* Auto-baud mode select bit. 0 - Mode 0, 1 - Mode 1. */ #define ASM9260_BM_AUTOBAUD_MODE BIT(1) /* * Auto-baud start (auto-baud is running). Auto-baud run bit. This bit is * automatically cleared after auto-baud completion.
*/ #define ASM9260_BM_AUTOBAUD_START BIT(0)
#define ASM9260_HW_CTRL3 0x00d0 #define ASM9260_BM_CTRL3_OUTCLK_DIV_MASK (0xffff << 16) /* * RW. Provide clk over OUTCLK pin. In case of asm9260 it can be configured on * pins 137 and 144.
*/ #define ASM9260_BM_CTRL3_MASTERMODE BIT(6) /* RW. Baud Rate Mode: 1 - Enable sync mode. 0 - async mode. */ #define ASM9260_BM_CTRL3_SYNCMODE BIT(4) /* RW. 1 - MSB bit send frist; 0 - LSB bit frist. */ #define ASM9260_BM_CTRL3_MSBF BIT(2) /* RW. 1 - sample rate = 8 x Baudrate; 0 - sample rate = 16 x Baudrate. */ #define ASM9260_BM_CTRL3_BAUD8 BIT(1) /* RW. 1 - Set word length to 9bit. 0 - use ASM9260_BM_LCTRL_WLEN */ #define ASM9260_BM_CTRL3_9BIT BIT(0)
/* [1] : send PIO. Note, the first pio word is CTRL1. */
pio = AUART_CTRL1_XFER_COUNT(size);
desc = dmaengine_prep_slave_sg(channel, (struct scatterlist *)&pio,
1, DMA_TRANS_NONE, 0); if (!desc) {
dev_err(s->dev, "step 1 error\n"); return -EINVAL;
}
/* [3] : submit the DMA, but do not issue it. */
desc->callback = dma_rx_callback;
desc->callback_param = s;
dmaengine_submit(desc);
dma_async_issue_pending(channel); return 0;
}
/* parity */ if (cflag & PARENB) {
ctrl |= AUART_LINECTRL_PEN; if ((cflag & PARODD) == 0)
ctrl |= AUART_LINECTRL_EPS; if (cflag & CMSPAR)
ctrl |= AUART_LINECTRL_SPS;
}
u->read_status_mask = AUART_STAT_OERR;
if (termios->c_iflag & INPCK)
u->read_status_mask |= AUART_STAT_PERR; if (termios->c_iflag & (IGNBRK | BRKINT | PARMRK))
u->read_status_mask |= AUART_STAT_BERR;
/* * Characters to ignore
*/
u->ignore_status_mask = 0; if (termios->c_iflag & IGNPAR)
u->ignore_status_mask |= AUART_STAT_PERR; if (termios->c_iflag & IGNBRK) {
u->ignore_status_mask |= AUART_STAT_BERR; /* * If we're ignoring parity and break indicators, * ignore overruns too (for real raw support).
*/ if (termios->c_iflag & IGNPAR)
u->ignore_status_mask |= AUART_STAT_OERR;
}
/* * ignore all characters if CREAD is not set
*/ if (cflag & CREAD)
ctrl2 |= AUART_CTRL2_RXE; else
ctrl2 &= ~AUART_CTRL2_RXE;
/* figure out the stop bits requested */ if (cflag & CSTOPB)
ctrl |= AUART_LINECTRL_STP2;
/* figure out the hardware flow control settings */
ctrl2 &= ~(AUART_CTRL2_CTSEN | AUART_CTRL2_RTSEN); if (cflag & CRTSCTS) { /* * The DMA has a bug(see errata:2836) in mx23. * So we can not implement the DMA for auart in mx23, * we can only implement the DMA support for auart * in mx28.
*/ if (is_imx28_auart(s)
&& test_bit(MXS_AUART_RTSCTS, &s->flags)) { if (!mxs_auart_dma_init(s)) /* enable DMA tranfer */
ctrl2 |= AUART_CTRL2_TXDMAE | AUART_CTRL2_RXDMAE
| AUART_CTRL2_DMAONERR;
} /* Even if RTS is GPIO line RTSEN can be enabled because
* the pinctrl configuration decides about RTS pin function */
ctrl2 |= AUART_CTRL2_RTSEN; if (CTS_AT_AUART())
ctrl2 |= AUART_CTRL2_CTSEN;
}
/* prepare for the DMA RX. */ if (auart_dma_enabled(s) &&
!test_and_set_bit(MXS_AUART_DMA_RX_READY, &s->flags)) { if (!mxs_auart_dma_prep_rx(s)) { /* Disable the normal RX interrupt. */
mxs_clr(AUART_INTR_RXIEN | AUART_INTR_RTIEN,
s, REG_INTR);
} else {
mxs_auart_dma_exit(s);
dev_err(s->dev, "We can not start up the DMA.\n");
}
}
/* CTS flow-control and modem-status interrupts */ if (UART_ENABLE_MS(u, termios->c_cflag))
mxs_auart_enable_ms(u); else
mxs_auart_disable_ms(u);
}
for (i = 0; i < 1000; i++) {
reg = mxs_read(s, REG_CTRL0); /* reset is finished when the clock is gated */ if (reg & AUART_CTRL0_CLKGATE) return;
udelay(10);
}
ret = clk_prepare_enable(s->clk); if (ret) return ret;
if (uart_console(u)) {
mxs_clr(AUART_CTRL0_CLKGATE, s, REG_CTRL0);
} else { /* reset the unit to a well known state */
mxs_auart_reset_assert(s);
mxs_auart_reset_deassert(s);
}
/* Reset FIFO size (it could have changed if DMA was enabled) */
u->fifosize = MXS_AUART_FIFO_SIZE;
/* * Enable fifo so all four bytes of a DMA word are written to * output (otherwise, only the LSB is written, ie. 1 in 4 bytes)
*/
mxs_set(AUART_LINECTRL_FEN, s, REG_LINECTRL);
/* get initial status of modem lines */
mctrl_gpio_get(s->gpios, &s->mctrl_prev);
/* Finally, wait for transmitter to become empty ... */ while (mxs_read(s, REG_STAT) & AUART_STAT_BUSY) {
udelay(1); if (!to--) break;
}
/* * ... and restore the TCR if we waited long enough for the transmitter * to be idle. This might keep the transmitter enabled although it is * unused, but that is better than to disable it while it is still * transmitting.
*/ if (!(mxs_read(s, REG_STAT) & AUART_STAT_BUSY)) {
mxs_write(old_ctrl0, s, REG_CTRL0);
mxs_write(old_ctrl2, s, REG_CTRL2);
}
clk_disable(s->clk);
}
staticvoid __init
auart_console_get_options(struct mxs_auart_port *s, int *baud, int *parity, int *bits)
{ struct uart_port *port = &s->port; unsignedint lcr_h, quot;
if (!(mxs_read(s, REG_CTRL2) & AUART_CTRL2_UARTEN)) return;
lcr_h = mxs_read(s, REG_LINECTRL);
*parity = 'n'; if (lcr_h & AUART_LINECTRL_PEN) { if (lcr_h & AUART_LINECTRL_EPS)
*parity = 'e'; else
*parity = 'o';
}
staticint __init
auart_console_setup(struct console *co, char *options)
{ struct mxs_auart_port *s; int baud = 9600; int bits = 8; int parity = 'n'; int flow = 'n'; int ret;
/* * Check whether an invalid uart number has been specified, and * if so, search for the first available port that does have * console support.
*/ if (co->index == -1 || co->index >= ARRAY_SIZE(auart_port))
co->index = 0;
s = auart_port[co->index]; if (!s) return -ENODEV;
ret = clk_prepare_enable(s->clk); if (ret) return ret;
s->gpios = mctrl_gpio_init_noauto(dev, 0); if (IS_ERR(s->gpios)) return PTR_ERR(s->gpios);
/* Block (enabled before) DMA option if RTS or CTS is GPIO line */ if (!RTS_AT_AUART() || !CTS_AT_AUART()) { if (test_bit(MXS_AUART_RTSCTS, &s->flags))
dev_warn(dev, "DMA and flow control via gpio may cause some problems. DMA disabled!\n");
clear_bit(MXS_AUART_RTSCTS, &s->flags);
}
for (i = 0; i < UART_GPIO_MAX; i++) {
gpiod = mctrl_gpio_to_gpiod(s->gpios, i); if (gpiod && (gpiod_get_direction(gpiod) == 1))
s->gpio_irq[i] = gpiod_to_irq(gpiod); else
s->gpio_irq[i] = -EINVAL;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.