mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Baeuerle, Florian" <Florian.Baeuerle@allegion.com>
To: "andrew.smirnov@gmail.com" <andrew.smirnov@gmail.com>
Cc: "barebox@lists.infradead.org" <barebox@lists.infradead.org>
Subject: Re: [PATCH] ARM: phytec-phycard-imx27: Add debug UART support
Date: Fri, 31 Aug 2018 09:46:50 +0000	[thread overview]
Message-ID: <94166a222e1d97e56a93eea02e419ea8adf86502.camel@allegion.com> (raw)
In-Reply-To: <CAHQ1cqFGjdRYJSiMtxfvhT-5dc14PszYGvhuikWOVVviMsHu0Q@mail.gmail.com>

Am Donnerstag, den 23.08.2018, 18:57 -0700 schrieb Andrey Smirnov:
> On Thu, Aug 23, 2018 at 2:59 AM Florian Bäuerle
> <florian.baeuerle@allegion.com> wrote:
> > 
> > Signed-off-by: Florian Bäuerle <florian.baeuerle@allegion.com>
> > ---
> >  arch/arm/boards/phytec-phycard-imx27/lowlevel.c | 15 +++++++++++++++
> >  arch/arm/mach-imx/include/mach/debug_ll.h       | 13 +++++++++++++
> >  include/serial/imx-uart.h                       |  5 +++++
> >  3 files changed, 33 insertions(+)
> > 
> > diff --git a/arch/arm/boards/phytec-phycard-imx27/lowlevel.c b/arch/arm/boards/phytec-phycard-imx27/lowlevel.c
> > index e1132e0..8244337 100644
> > --- a/arch/arm/boards/phytec-phycard-imx27/lowlevel.c
> > +++ b/arch/arm/boards/phytec-phycard-imx27/lowlevel.c
> > @@ -14,6 +14,8 @@
> >  #include <mach/imx-pll.h>
> >  #include <mach/esdctl.h>
> >  #include <mach/imx-nand.h>
> > +#include <mach/debug_ll.h>
> > +#include <serial/imx-uart.h>
> > 
> >  #define ESDCTL0_VAL (ESDCTL0_SDE | ESDCTL0_ROW13 | ESDCTL0_COL10)
> > 
> > @@ -58,6 +60,18 @@ static void sdram_init(void)
> >                         MX27_ESDCTL_BASE_ADDR + IMX_ESDCTL0);
> >  }
> > 
> > +static void setup_uart(void)
> > +{
> > +       /* Set PE[12-15] use, direction, function and pull-up */
> > +       writel(0xfffc0f27, MX27_GPIO5_BASE_ADDR + 0x20);
> > +       writel(0x00005000, MX27_GPIO5_BASE_ADDR);
> > +       writel(0x00000000, MX27_GPIO5_BASE_ADDR + 0x38);
> > +       writel(0xffff0fff, MX27_GPIO5_BASE_ADDR + 0x40);
> > +
> 
> Can constants from iomux-imx27.h be used here?

In theory yes, it could be done with imx_gpio_mode(). I think it's better to
leave it as is, otherwise, we'd need a) the pinctrl driver in
the pbl (probably
too large) or b) do the same as imx_gpio_mode and extract the ORed values from a
newly defined constant and basically
reimplement imx_gpio_mode.

The register offsets are also only defined in drivers/pinctrl/imx-iomux-v1.c

> 
> > +       imx27_ungate_all_peripherals();
> > +       imx27_uart_setup_ll();
> > +}
> > +
> >  void __bare_init __naked phytec_phycard_imx27_common_init(void *fdt)
> >  {
> >         unsigned long r;
> > @@ -97,6 +111,7 @@ void __bare_init __naked phytec_phycard_imx27_common_init(void *fdt)
> >                 MX27_CSCR_MSHC_SEL, MX27_CCM_BASE_ADDR + MX27_CSCR);
> > 
> >         sdram_init();
> > +       setup_uart();
> 
> Majority of the boards gates this to happen on if
> IS_ENABLED(CONFIG_DEBUG_LL) is true, so it might make sense to do the
> same.

you're right.

> 
> > 
> >         imx27_barebox_boot_nand_external(fdt);
> >  }
> > diff --git a/arch/arm/mach-imx/include/mach/debug_ll.h b/arch/arm/mach-imx/include/mach/debug_ll.h
> > index 1550e05..6c9b21d 100644
> > --- a/arch/arm/mach-imx/include/mach/debug_ll.h
> > +++ b/arch/arm/mach-imx/include/mach/debug_ll.h
> > @@ -56,6 +56,12 @@
> >  #error "unknown i.MX debug uart soc type"
> >  #endif
> > 
> > +static inline void imx27_uart_setup_ll(void)  {
> > +       void *base = IOMEM(IMX_UART_BASE(IMX_DEBUG_SOC,
> > +                               CONFIG_DEBUG_IMX_UART_PORT));
> > +       imx27_uart_setup(base);
> > +}
> > +
> >  static inline void imx50_uart_setup_ll(void)
> >  {
> >         void *base = IOMEM(IMX_UART_BASE(IMX_DEBUG_SOC, CONFIG_DEBUG_IMX_UART_PORT));
> > @@ -121,6 +127,7 @@ static inline void PUTC_LL(int c)
> > 
> >  #else
> > 
> > +static inline void imx27_uart_setup_ll(void) {}
> >  static inline void imx50_uart_setup_ll(void) {}
> >  static inline void imx51_uart_setup_ll(void) {}
> >  static inline void imx53_uart_setup_ll(void) {}
> > @@ -138,6 +145,12 @@ static inline void imx_ungate_all_peripherals(void __iomem *ccmbase)
> >                 writel(0xffffffff, ccmbase + i);
> >  }
> > 
> > +static inline void imx27_ungate_all_peripherals(void)
> > +{
> > +       writel(0xfffffbff, IOMEM(MX27_CCM_BASE_ADDR) + 0x20);
> > +       writel(0xfffffffc, IOMEM(MX27_CCM_BASE_ADDR) + 0x24);
> > +}
> 
> I think you can use  MX27_PCCR0 and  MX27_PCCR1 here instead of magic numbers.

yep, thanks.

> 
> > +
> >  static inline void imx6_ungate_all_peripherals(void)
> >  {
> >         imx_ungate_all_peripherals(IOMEM(MX6_CCM_BASE_ADDR));
> > diff --git a/include/serial/imx-uart.h b/include/serial/imx-uart.h
> > index c236065..0c033c2 100644
> > --- a/include/serial/imx-uart.h
> > +++ b/include/serial/imx-uart.h
> > @@ -155,6 +155,11 @@ static inline void imx_uart_set_dte(void __iomem *uartbase)
> >         writel(ufcr, uartbase + UFCR);
> >  }
> > 
> > +static inline void imx27_uart_setup(void __iomem *uartbase)
> > +{
> > +       imx_uart_setup(uartbase, 66500000);
> > +}
> > +
> >  static inline void imx50_uart_setup(void __iomem *uartbase)
> >  {
> >         imx_uart_setup(uartbase, 66666666);
> > --
> > 1.8.3.1
> > 
> > 
> > _______________________________________________
> > barebox mailing list
> > barebox@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/barebox
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2018-08-31  9:47 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-23  9:58 Florian Bäuerle
2018-08-23 12:20 ` Baeuerle, Florian
2018-08-24  7:16   ` Sascha Hauer
2018-08-27 12:10   ` Sascha Hauer
2018-08-27 12:37     ` Baeuerle, Florian
2018-08-27 14:45       ` s.hauer
2018-08-24  1:57 ` Andrey Smirnov
2018-08-31  9:46   ` Baeuerle, Florian [this message]
2018-09-10  8:05     ` [PATCH v2] " Florian Bäuerle

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=94166a222e1d97e56a93eea02e419ea8adf86502.camel@allegion.com \
    --to=florian.baeuerle@allegion.com \
    --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