[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH RFC 1/6] xen/arm: platforms: Add earlyprintk and serial support for Tegra boards.



On Tue, 13 Sep 2016, Konrad Rzeszutek Wilk wrote:
> On Mon, Sep 05, 2016 at 06:13:56AM -0400, Kyle Temkin wrote:
> > From: "Kyle J. Temkin" <temkink@xxxxxxxxxxxx>
> > 
> > Tegra boards feature a NS16550-compatible serial mapped into the MMIO
> > space. Add support for its use both as a full-featured serial port and
> > as an earlyprintk driver.
> > 
> > Adds a new "needs_rtoie" (requires Rx Timeout Interrupt) quirk, as some
> > platforms-- including Tegra-- require the NS16550 Rx timeout interrupt
> > to be enabled for receive to function properly. The same quirk is
> > applied in the eqvuialent Linux driver [1].
                     ^ equivalent


> > [1] 
> > https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=4539c24fe4f92c09ee668ef959d3e8180df619b9
> > 
> > Signed-off-by: Kyle Temkin <temkink@xxxxxxxxxxxx>
> > ---
> >  xen/arch/arm/Rules.mk       |  1 +
> >  xen/drivers/char/ns16550.c  | 16 +++++++++++++++-
> >  xen/include/xen/8250-uart.h |  1 +
> >  3 files changed, 17 insertions(+), 1 deletion(-)
> > 
> > diff --git a/xen/arch/arm/Rules.mk b/xen/arch/arm/Rules.mk
> > index 93304be..2a1473a 100644
> > --- a/xen/arch/arm/Rules.mk
> > +++ b/xen/arch/arm/Rules.mk
> > @@ -44,6 +44,7 @@ EARLY_PRINTK_vexpress       := pl011,0x1c090000
> >  EARLY_PRINTK_xgene-mcdivitt := 8250,0x1c021000,2
> >  EARLY_PRINTK_xgene-storm    := 8250,0x1c020000,2
> >  EARLY_PRINTK_zynqmp         := cadence,0xff000000
> > +EARLY_PRINTK_tegra          := 8250,0x70006000,2
> >  
> >  ifneq ($(EARLY_PRINTK_$(CONFIG_EARLY_PRINTK)),)
> >  EARLY_PRINTK_CFG := $(subst $(comma), 
> > ,$(EARLY_PRINTK_$(CONFIG_EARLY_PRINTK)))
> > diff --git a/xen/drivers/char/ns16550.c b/xen/drivers/char/ns16550.c
> > index 1da103a..bffdb35 100644
> > --- a/xen/drivers/char/ns16550.c
> > +++ b/xen/drivers/char/ns16550.c
> > @@ -64,6 +64,7 @@ static struct ns16550 {
> >      unsigned int timeout_ms;
> >      bool_t intr_works;
> >      bool_t dw_usr_bsy;
> > +    bool_t needs_rtoie;
> 
> Those three states all look like tri-states? Or could you potentially
> have them independenty enabled? As in dw_usr_bsy and needs_rtoie?

Yes, it would be nice to turn dw_usr_bsy and needs_rtoie, which are
hardware features/workarounds, into a bitmask. Something like:

  #define DW_USR_BSY  (1<<0)
  #define NEEDS_RTOIE (1<<1)
  uint8_t hw_feats;

 
> >  #ifdef CONFIG_HAS_PCI
> >      /* PCI card parameters. */
> >      bool_t pb_bdf_enable;   /* if =1, pb-bdf effective, port behind bridge 
> > */
> > @@ -652,12 +653,23 @@ static void ns16550_setup_postirq(struct ns16550 
> > *uart)
> >  {
> >      if ( uart->irq > 0 )
> >      {
> > +        u8 ier_value = 0;
> > +
> >          /* Master interrupt enable; also keep DTR/RTS asserted. */
> >          ns_write_reg(uart,
> >                       UART_MCR, UART_MCR_OUT2 | UART_MCR_DTR | 
> > UART_MCR_RTS);
> >  
> >          /* Enable receive interrupts. */
> > -        ns_write_reg(uart, UART_IER, UART_IER_ERDAI);
> > +        ier_value = UART_IER_ERDAI;
> > +
> > +        /*
> > +         * If we're on a platform that needs Rx timeouts enabled, also
> > +         * set Rx TimeOut Interrupt Enable (RTOIE).
> > +         */
> > +        if ( uart->needs_rtoie )
> > +          ier_value |= UART_IER_RTOIE;
> > +
> > +        ns_write_reg(uart, UART_IER, ier_value);
> >      }
> >  
> >      if ( uart->irq >= 0 )
> > @@ -1273,6 +1285,7 @@ static int __init ns16550_uart_dt_init(struct 
> > dt_device_node *dev,
> >      uart->irq = res;
> >  
> >      uart->dw_usr_bsy = dt_device_is_compatible(dev, "snps,dw-apb-uart");
> > +    uart->needs_rtoie = dt_device_is_compatible(dev, 
> > "nvidia,tegra20-uart");
> >  
> >      uart->vuart.base_addr = uart->io_base;
> >      uart->vuart.size = uart->io_size;
> > @@ -1293,6 +1306,7 @@ static const struct dt_device_match 
> > ns16550_dt_match[] __initconst =
> >      DT_MATCH_COMPATIBLE("ns16550"),
> >      DT_MATCH_COMPATIBLE("ns16550a"),
> >      DT_MATCH_COMPATIBLE("snps,dw-apb-uart"),
> > +    DT_MATCH_COMPATIBLE("nvidia,tegra20-uart"),
> >      { /* sentinel */ },
> >  };
> >  
> > diff --git a/xen/include/xen/8250-uart.h b/xen/include/xen/8250-uart.h
> > index c6b62c8..2ad0ee6 100644
> > --- a/xen/include/xen/8250-uart.h
> > +++ b/xen/include/xen/8250-uart.h
> > @@ -41,6 +41,7 @@
> >  #define UART_IER_ETHREI   0x02    /* tx reg. empty        */
> >  #define UART_IER_ELSI     0x04    /* rx line status       */
> >  #define UART_IER_EMSI     0x08    /* MODEM status         */
> > +#define UART_IER_RTOIE    0x10    /* rx timeout           */
> >  
> >  /* Interrupt Identificatiegister */
> >  #define UART_IIR_NOINT    0x01    /* no interrupt pending */
> > -- 
> > 2.9.2
> > 
> > 
> > _______________________________________________
> > Xen-devel mailing list
> > Xen-devel@xxxxxxxxxxxxx
> > https://lists.xen.org/xen-devel
> 

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
https://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.