mirror of
https://github.com/torvalds/linux.git
synced 2026-11-29 10:07:52 +00:00
Currently, uart_console_write->putchar's second parameter (the character) is of type int. It makes little sense, provided uart_console_write() accepts the input string as "const char *s" and passes its content -- the characters -- to putchar(). So switch the character's type to unsigned char. We don't use char as that is signed on some platforms. That would cause troubles for drivers which (implicitly) cast the char to u16 when writing to the device. Sign extension would happen in that case and the value written would be completely different to the provided char. DZ is an example of such a driver -- on MIPS, it uses u16 for dz_out in dz_console_putchar(). Note we do the char -> uchar conversion implicitly in uart_console_write(). Provided we do not change size of the data type, sign extension does not happen there, so the problem is void. This makes the types consistent and unified with the rest of the uart layer, which uses unsigned char in most places already. One exception is xmit_buf, but that is going to be converted later. Cc: Paul Cercueil <[email protected]> Cc: Tobias Klauser <[email protected]> Cc: Russell King <[email protected]> Cc: Vineet Gupta <[email protected]> Cc: Nicolas Ferre <[email protected]> Cc: Alexandre Belloni <[email protected]> Cc: Ludovic Desroches <[email protected]> Cc: Florian Fainelli <[email protected]> Cc: [email protected] Cc: Alexander Shiyan <[email protected]> Cc: Baruch Siach <[email protected]> Cc: "Maciej W. Rozycki" <[email protected]> Cc: Paul Walmsley <[email protected]> Cc: Palmer Dabbelt <[email protected]> Cc: Albert Ou <[email protected]> Cc: Shawn Guo <[email protected]> Cc: Sascha Hauer <[email protected]> Cc: Pengutronix Kernel Team <[email protected]> Cc: Fabio Estevam <[email protected]> Cc: NXP Linux Team <[email protected]> Cc: Karol Gugala <[email protected]> Cc: Mateusz Holenko <[email protected]> Cc: Vladimir Zapolskiy <[email protected]> Cc: Neil Armstrong <[email protected]> Cc: Kevin Hilman <[email protected]> Cc: Jerome Brunet <[email protected]> Cc: Martin Blumenstingl <[email protected]> Cc: Taichi Sugaya <[email protected]> Cc: Takao Orito <[email protected]> Cc: Liviu Dudau <[email protected]> Cc: Sudeep Holla <[email protected]> Cc: Lorenzo Pieralisi <[email protected]> Cc: "Andreas Färber" <[email protected]> Cc: Manivannan Sadhasivam <[email protected]> Cc: Michael Ellerman <[email protected]> Cc: Benjamin Herrenschmidt <[email protected]> Cc: Paul Mackerras <[email protected]> Cc: Andy Gross <[email protected]> Cc: Bjorn Andersson <[email protected]> Cc: Krzysztof Kozlowski <[email protected]> Cc: Orson Zhai <[email protected]> Cc: Baolin Wang <[email protected]> Cc: Chunyan Zhang <[email protected]> Cc: Patrice Chotard <[email protected]> Cc: Maxime Coquelin <[email protected]> Cc: Alexandre Torgue <[email protected]> Cc: "David S. Miller" <[email protected]> Cc: Peter Korsgaard <[email protected]> Cc: Michal Simek <[email protected]> Acked-by: Richard Genoud <[email protected]> [atmel_serial] Acked-by: Uwe Kleine-König <[email protected]> Acked-by: Paul Cercueil <[email protected]> Acked-by: Neil Armstrong <[email protected]> # meson_serial Signed-off-by: Jiri Slaby <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
51 lines
1.3 KiB
C
51 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0+
|
|
/*
|
|
* Copyright 2020 NXP
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/ioport.h>
|
|
#include <linux/init.h>
|
|
#include <linux/serial_core.h>
|
|
#include <linux/serial.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/of.h>
|
|
#include <linux/io.h>
|
|
|
|
#define URTX0 0x40 /* Transmitter Register */
|
|
#define UTS_TXFULL (1<<4) /* TxFIFO full */
|
|
#define IMX21_UTS 0xb4 /* UART Test Register on all other i.mx*/
|
|
|
|
static void imx_uart_console_early_putchar(struct uart_port *port, unsigned char ch)
|
|
{
|
|
while (readl_relaxed(port->membase + IMX21_UTS) & UTS_TXFULL)
|
|
cpu_relax();
|
|
|
|
writel_relaxed(ch, port->membase + URTX0);
|
|
}
|
|
|
|
static void imx_uart_console_early_write(struct console *con, const char *s,
|
|
unsigned count)
|
|
{
|
|
struct earlycon_device *dev = con->data;
|
|
|
|
uart_console_write(&dev->port, s, count, imx_uart_console_early_putchar);
|
|
}
|
|
|
|
static int __init
|
|
imx_console_early_setup(struct earlycon_device *dev, const char *opt)
|
|
{
|
|
if (!dev->port.membase)
|
|
return -ENODEV;
|
|
|
|
dev->con->write = imx_uart_console_early_write;
|
|
|
|
return 0;
|
|
}
|
|
OF_EARLYCON_DECLARE(ec_imx6q, "fsl,imx6q-uart", imx_console_early_setup);
|
|
OF_EARLYCON_DECLARE(ec_imx21, "fsl,imx21-uart", imx_console_early_setup);
|
|
|
|
MODULE_AUTHOR("NXP");
|
|
MODULE_DESCRIPTION("IMX earlycon driver");
|
|
MODULE_LICENSE("GPL");
|