mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v3 04/18] i.MX: serial: Add UART init functions for DEBUG_LL
Date: Thu, 7 May 2015 09:52:40 +0200	[thread overview]
Message-ID: <20150507075240.GN6325@pengutronix.de> (raw)
In-Reply-To: <1430940733-4415-5-git-send-email-andrew.smirnov@gmail.com>

On Wed, May 06, 2015 at 12:31:59PM -0700, Andrey Smirnov wrote:
> It appears that all i.MX51 and i.MX6 based boards that support early
> debug output inevitably do exactly the same thing with the registers
> of the UART peripheral. So to avoid code duplication three new
> subroutines are introduced:
> 
>   - imx_uart_setup_ll() that allows user to perform aforementioned
>     "same thing" on any arbitrary UART at 'uartbase' and clocked at
>     'refclock' Hz.
> 
>   - imx6_uart_setup_ll() and imx5_uart_setup_ll() that do those
>     actions assuming UART to be the one specified in configuration and
>     'refclock' to be equal to what it is when SoC comes out of reset.
> 
> NOTE: Please note that 'imx*_uart_setup_ll' functions do add a slight
> difference in behaviour by dropping the initialization of ONEMS and
> UESC registers since those do not seem to be needed for early UART
> functionality
> 
> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
> ---
>  arch/arm/mach-imx/include/mach/debug_ll.h | 55 +++++++++++++++++++++++++++++--
>  1 file changed, 53 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-imx/include/mach/debug_ll.h b/arch/arm/mach-imx/include/mach/debug_ll.h
> index 31371e2..baf7f53 100644
> --- a/arch/arm/mach-imx/include/mach/debug_ll.h
> +++ b/arch/arm/mach-imx/include/mach/debug_ll.h
> @@ -3,6 +3,7 @@
>  
>  #include <io.h>
>  #include <config.h>
> +#include <common.h>
>  #include <mach/imx1-regs.h>
>  #include <mach/imx21-regs.h>
>  #include <mach/imx25-regs.h>
> @@ -17,6 +18,36 @@
>  
>  #ifdef CONFIG_DEBUG_LL
>  
> +#define __IMX_UART_BASE(soc, num) soc##_UART##num##_BASE_ADDR
> +#define IMX_UART_BASE(soc, num) __IMX_UART_BASE(soc, num)
> +
> +static inline void imx_uart_setup_ll(void __iomem *uartbase,
> +				     unsigned int refclock)
> +{
> +	writel(0x00000000, uartbase + UCR1);
> +
> +	writel(UCR2_IRTS | UCR2_WS | UCR2_TXEN | UCR2_RXEN | UCR2_SRST,
> +	       uartbase + UCR2);
> +	writel(UCR3_DSR | UCR3_DCD | UCR3_RI | UCR3_ADNIMP | UCR3_RXDMUXSEL,
> +	       uartbase + UCR3);
> +	writel((0b10 << UFCR_TXTL_SHF) | UFCR_RFDIV1 | (1 << UFCR_RXTL_SHF),
> +	       uartbase + UFCR);
> +
> +	writel(baudrate_to_ubir(CONFIG_BAUDRATE),
> +	       uartbase + UBIR);
> +	writel(refclock_to_ubmr(refclock),
> +	       uartbase + UBMR);
> +
> +	writel(UCR1_UARTEN, uartbase + UCR1);
> +}
> +
> +#define __imx_uart_setup_ll(refclock)					\
> +	do {								\
> +		imx_uart_setup_ll(IOMEM(IMX_UART_BASE(IMX_DEBUG_SOC,	\
> +						      CONFIG_DEBUG_IMX_UART_PORT)), \
> +				  refclock);				\
> +	} while(0)
> +
>  #ifdef CONFIG_DEBUG_IMX1_UART
>  #define IMX_DEBUG_SOC MX1
>  #elif defined CONFIG_DEBUG_IMX21_UART
> @@ -39,8 +70,19 @@
>  #error "unknown i.MX debug uart soc type"
>  #endif
>  
> -#define __IMX_UART_BASE(soc, num) soc##_UART##num##_BASE_ADDR
> -#define IMX_UART_BASE(soc, num) __IMX_UART_BASE(soc, num)
> +static inline void imx51_uart_setup_ll(void)
> +{
> +#if defined CONFIG_DEBUG_IMX51_UART
> +	__imx_uart_setup_ll(54000000);
> +#endif
> +}
> +
> +static inline void imx6_uart_setup_ll(void)
> +{
> +#if defined CONFIG_DEBUG_IMX6Q_UART
> +	__imx_uart_setup(80000000);
> +#endif

Typo here, should be __imx_uart_setup_ll like above. I also removed the
#ifdefs which seem unnecessary.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2015-05-07  7:53 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-06 19:31 [PATCH v3 00/18] i.MX serial cleanup, bootstrap code fixes, boot via IRAM Andrey Smirnov
2015-05-06 19:31 ` [PATCH v3 01/18] i.MX: Move UART definitions into a separate file Andrey Smirnov
2015-05-06 19:31 ` [PATCH v3 02/18] i.MX: serial: Add constants for UART clock divisor Andrey Smirnov
2015-05-06 19:31 ` [PATCH v3 03/18] i.MX: serial: Add baud rate calculation convenience functions Andrey Smirnov
2015-05-06 19:31 ` [PATCH v3 04/18] i.MX: serial: Add UART init functions for DEBUG_LL Andrey Smirnov
2015-05-07  7:52   ` Sascha Hauer [this message]
2015-05-06 19:32 ` [PATCH v3 05/18] i.MX: serial: Convert PUTC_LL to use IOMEM Andrey Smirnov
2015-05-06 19:32 ` [PATCH v3 06/18] i.MX: serial: Convert i.MX51 and i.MX6 to use 'imx*_uart_setup_ll' Andrey Smirnov
2015-05-06 19:32 ` [PATCH v3 07/18] i.MX51: babbage: Implement CONFIG_DEBUG_LL Andrey Smirnov
2015-05-07  7:57   ` Sascha Hauer
2015-05-06 19:32 ` [PATCH v3 08/18] i.MX: serial: Distil common clock ungating code Andrey Smirnov
2015-05-07  7:56   ` Sascha Hauer
2015-05-06 19:32 ` [PATCH v3 09/18] Makefile.lib: Make 'check_file_size' more flexible Andrey Smirnov
2015-05-06 19:32 ` [PATCH v3 10/18] i.MX: Add provisions to boot from IRAM Andrey Smirnov
2015-05-06 19:32 ` [PATCH v3 11/18] imx-image: Correctly fill image size in prepended header Andrey Smirnov
2015-05-06 19:32 ` [PATCH v3 12/18] bootstrap: Fix potential memory leak in 'read_image_head' Andrey Smirnov
2015-05-06 19:32 ` [PATCH v3 13/18] bootstrap_read_devfs(): Check for errors from devfs_add_partition() Andrey Smirnov
2015-05-06 19:32 ` [PATCH v3 14/18] bootstrap_read_devfs(): Close file after we are done with it Andrey Smirnov
2015-05-06 19:32 ` [PATCH v3 15/18] bootstrap_read_devfs(): Fix potential memory leak Andrey Smirnov
2015-05-06 19:32 ` [PATCH v3 16/18] bootstrap_read_devfs(): Check for errors from dev_add_bb_dev() Andrey Smirnov
2015-05-06 19:32 ` [PATCH v3 17/18] bootstrap_read_devfs(): Remove all partitions upon function completion Andrey Smirnov
2015-05-06 19:32 ` [PATCH v3 18/18] bootstrap: Warn if image size in BB header is zero Andrey Smirnov
2015-05-07  7:51 ` [PATCH v3 00/18] i.MX serial cleanup, bootstrap code fixes, boot via IRAM Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150507075240.GN6325@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=andrew.smirnov@gmail.com \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox