[U-Boot] [RFC][PATCH v4] ARM: mxs: Added application UART driver

Marek Vasut
2013-08-14T19:20:00Z

Dear Andreas Wass,

> The driver makes it possible to use an application UART as
> the U-Boot output console for Freescale i.MX23/i.MX28 devices.
>
> Signed-off-by: Andreas Wass <andreas.wass@dalelven.com>
> Cc: Fabio Estevam <fabio.estevam@freescale.com>
> Cc: Marek Vasut <marex@denx.de>
> ---
> Changes for v2:
> - Added comment that regs-uartapp.h is pulled from LTIB
> - BM_ prefixes removed and _MASK suffixes added instead
> - BP_ prefixes removed and _OFFSET suffixes added instead
> - BF_ defines removed altogether
> - CONFIG_MXS_AUART_CLK renamed to MXS_AUART_CLK and guarding ifndef
> removed - Added comments describing what is set and unset during init of
> driver - Added newline that was accidently removed from serial.c
>
> Changes for v3:
> - All BV_ values are now on the form (value << something)
> - BV_ prefix removed and double underscore substituted with a single
> - File comment of mxs_auart.c now attributes what the driver is based on
> - Uses gd->baudrate instead of CONFIG_BAUDRATE
> - If gd->baudrate is 0 it reverts back to CONFIG_BAUDRATE
> - Checks the validity of the div value calculated when setting the
> baudrate - Magic numbers are now defines instead
> - Cleanup of comments
> - Cleanup of commit message
>
> Changes for v4:
> - Fixed UARTAPP_LINECTRL2_WLEN_*BITS values
>
> drivers/serial/Makefile | 1 +
> drivers/serial/mxs_auart.c | 151 ++++++++++++++++
> drivers/serial/serial.c | 2 +
> 4 files changed, 403 insertions(+)
> create mode 100644 arch/arm/include/asm/arch-mxs/regs-uartapp.h
> create mode 100644 drivers/serial/mxs_auart.c
>
> diff --git a/arch/arm/include/asm/arch-mxs/regs-uartapp.h
> b/arch/arm/include/asm/arch-mxs/regs-uartapp.h new file mode 100644
> index 0000000..abd62c2
> --- /dev/null
> +++ b/arch/arm/include/asm/arch-mxs/regs-uartapp.h
> @@ -0,0 +1,249 @@
> +/*
> + * Freescale MXS UARTAPP Register Definitions
> + *
> + * Copyright (C) 2013 Andreas Wass <andreas.wass@dalelven.com>
> + *
> + * Based on code from LTIB:
> + * Copyright 2008-2010 Freescale Semiconductor, Inc. All Rights Reserved.
> + *
> + * SPDX-License-Identifier: GPL-2.0+
> + */
> +
> +#ifndef __ARCH_ARM___MXS_UARTAPP_H
> +#define __ARCH_ARM___MXS_UARTAPP_H
> +
> +#include <asm/imx-common/regs-common.h>
> +
> +#ifndef __ASSEMBLY__
> +struct mxs_uartapp_regs {
> + mxs_reg_32(hw_uartapp_ctrl0)
> + mxs_reg_32(hw_uartapp_ctrl1)
> + mxs_reg_32(hw_uartapp_ctrl2)
> + mxs_reg_32(hw_uartapp_linectrl)
> + mxs_reg_32(hw_uartapp_linectrl2)
> + mxs_reg_32(hw_uartapp_intr)
> + mxs_reg_32(hw_uartapp_data)
> + mxs_reg_32(hw_uartapp_stat)
> + mxs_reg_32(hw_uartapp_debug)
> + mxs_reg_32(hw_uartapp_version)
> + mxs_reg_32(hw_uartapp_autobaud)
> +};
> +#endif
> +
> +
> +#define UARTAPP_CTRL0_SFTRST_MASK (1 << 31)
> +#define UARTAPP_CTRL0_CLKGATE_MASK (1 << 30)
> +#define UARTAPP_CTRL0_RUN_MASK (1 << 29)
> +#define UARTAPP_CTRL0_RX_SOURCE_MASK (1 << 28)
> +#define UARTAPP_CTRL0_RXTO_ENABLE_MASK (1 << 27)
> +#define UARTAPP_CTRL0_RXTIMEOUT_OFFSET (1 << 4)
> +#define UARTAPP_CTRL0_RXTIMEOUT_MASK 0x07FF0000
> +#define UARTAPP_CTRL0_XFER_COUNT_OFFSET 0
> +#define UARTAPP_CTRL0_XFER_COUNT_MASK 0x0000FFFF

Two minor nits, replace this with 0xffff

> +#define UARTAPP_CTRL1_RSVD2_OFFSET 29
> +#define UARTAPP_CTRL1_RSVD2_MASK 0xE0000000
> +
> +#define UARTAPP_CTRL1_RUN_MASK (1 << 28)
> +#define UARTAPP_CTRL1_RSVD1_OFFSET 16
> +#define UARTAPP_CTRL1_RSVD1_MASK 0x0FFF0000

Here this would be (0xfff << 16) to keep consistent.

Moreover, you can drop the RSVD portions.
[...]

The rest is good.

Best regards,
Marek Vasut