Esempio n. 1
0
static int uniphier_serial_getc(struct udevice *dev)
{
	struct uniphier_serial __iomem *port = uniphier_serial_port(dev);

	if (!(readb(&port->lsr) & UART_LSR_DR))
		return -EAGAIN;

	return readb(&port->rbr);
}
Esempio n. 2
0
static int uniphier_serial_pending(struct udevice *dev, bool input)
{
	struct uniphier_serial __iomem *port = uniphier_serial_port(dev);

	if (input)
		return readl(&port->lsr) & UART_LSR_DR;
	else
		return !(readl(&port->lsr) & UART_LSR_THRE);
}
Esempio n. 3
0
static int uniphier_serial_putc(struct udevice *dev, const char c)
{
	struct uniphier_serial __iomem *port = uniphier_serial_port(dev);

	if (!(readb(&port->lsr) & UART_LSR_THRE))
		return -EAGAIN;

	writeb(c, &port->thr);

	return 0;
}
Esempio n. 4
0
static int uniphier_serial_setbrg(struct udevice *dev, int baudrate)
{
	struct uniphier_serial_private_data *priv = dev_get_priv(dev);
	struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
	const unsigned int mode_x_div = 16;
	unsigned int divisor;

	divisor = DIV_ROUND_CLOSEST(priv->uartclk, mode_x_div * baudrate);

	writel(divisor, &port->dlr);

	return 0;
}
Esempio n. 5
0
int uniphier_serial_setbrg(struct udevice *dev, int baudrate)
{
	struct uniphier_serial_platform_data *plat = dev_get_platdata(dev);
	struct uniphier_serial __iomem *port = uniphier_serial_port(dev);
	const unsigned int mode_x_div = 16;
	unsigned int divisor;

	writeb(UART_LCR_WLS_8, &port->lcr);

	divisor = DIV_ROUND_CLOSEST(plat->uartclk, mode_x_div * baudrate);

	writew(divisor, &port->dlr);

	return 0;
}
Esempio n. 6
0
int uniphier_serial_remove(struct udevice *dev)
{
	unmap_sysmem(uniphier_serial_port(dev));

	return 0;
}