2009-11-12 04:15:57     quad uart

Document created by Aaronwu Employee on Aug 19, 2013
Version 1Show Document
  • View in full screen mode

2009-11-12 04:15:57     quad uart

Filip Vanalme (BELGIUM)

Message: 82304   

 

Hi,

 

Before diving into Kernel sources, I would like to post my problem here. Maybe someone can point me in the good direction...

 

from my application, I can open serial devices, e.g. ttyS0 and ttyS1. No error at this point. Any action I try after that on that open device, e.g. an ioctl call or a read, fails with an "input/output error" message. Can this problem be related to hardware problems ? If, for some reason the uart is not accessible, does this cause this kind of error message ? I wouldn't expect an error message for that, but wrong values. Or is this problem related to the interface between user space and kernel device ?

 

This is a fragment of my ezkit.c file :

 

#define UART16C554_BASE   0x28000000

 

static struct plat_serial8250_port uart_16c554_data [] = {

  {

    .membase = (void __iomem *)(UART16C554_BASE + 0x70),

    .mapbase = UART16C554_BASE + 0x70,

    .irq = IRQ_PF12,

    .flags = UPF_BOOT_AUTOCONF,

    .iotype = UPIO_MEM,

    .regshift = 1,

    .uartclk = 1843200,

  },

  {

    .membase = (void __iomem *)(UART16C554_BASE + 0xB0),

    .mapbase = UART16C554_BASE + 0xB0,

    .irq = IRQ_PF6,

    .flags = UPF_BOOT_AUTOCONF,

    .iotype = UPIO_MEM,

    .regshift = 1,

    .uartclk = 1843200,

  },

  {

    .membase = (void __iomem *)(UART16C554_BASE + 0xD0),

    .mapbase = UART16C554_BASE + 0xD0,

    .irq = IRQ_PF7,

    .flags = UPF_BOOT_AUTOCONF,

    .iotype = UPIO_MEM,

    .regshift = 1,

    .uartclk = 1843200,

  },

  {

    .membase = (void __iomem *)(UART16C554_BASE + 0xE0),

    .mapbase = UART16C554_BASE + 0xE0,

    .irq = IRQ_PF8,

    .flags = UPF_BOOT_AUTOCONF,

    .iotype = UPIO_MEM,

    .regshift = 1,

    .uartclk = 1843200,

  },

  {}

};

 

static struct platform_device uart_16c554_device = {

  .name     = "serial8250",

  .id     = PLAT8250_DEV_PLATFORM,

  .dev.platform_data  = uart_16c554_data,

};

 

This is part of my cplbtab.h file :

 

.global _dpdt_table;

_dpdt_table:

.byte4 0xFF800000;

.byte4 (L1_DMEMORY);

.byte4 0xFEB00000;

.byte4 (L2_DMEMORY);

.byte4 0x2C000000;

.byte4 (AMB_NETWORK);

.byte4 0x28000000;

.byte4 (AMB_NETWORK);

.byte4  0x20000000;

.byte4  (AMB_DGENERIC); //_LIN_CACHE_, (AMB_KERNEL);

.byte4  0x20400000;

.byte4  (AMB_DGENERIC); //_LIN_CACHE_, (AMB_KERNEL);

.byte4 0x20800000; //_LIN_CACHE_: 16M FLASH

 

And this is part of my (test) application code :

 

  int fd;

  int retVal;

  unsigned char data[20];

  int status;

  unsigned char *dev = "/dev/ttyS0";

 

  printf ("Open %s\n", dev);

  fd = open (dev, O_RDWR | O_NONBLOCK | O_NOCTTY);

  if (fd < 0)

  {

    printf ("OPEN : %s\n", strerror(errno));

    return;

  }

  printf ("%s open\n", dev);

#define TIOCMGET    0x5415

  if (ioctl(fd, TIOCMGET, &status) < 0)

  {

    printf ("IOCTL : %s(%d)\n", strerror(errno), errno);

  }

  else

  {

    printf ("Status : %x", status);

  }

 

  printf ("Reading device\n");

  retVal = read (fd, data, 10);

  if (retVal < 0)

  {

    printf ("%s\n", strerror(errno));

  }

 

  close (fd);

 

The console output for that piece of code looks like :

 

Open /dev/ttyS0

/dev/ttyS0 open

IOCTL : Input/output error(5)

Reading device

Input/output error

 

 

 

Filip

TranslateQuoteReplyEditDelete

 

 

2009-11-12 05:34:02     Re: quad uart

Sonic Zhang (CHINA)

Message: 82307   

 

Which release do you use?

 

There is not ttyS0 and ttyS1 since 2008R1 release.

QuoteReplyEditDelete

 

 

2009-11-12 05:36:04     Re: quad uart

Sonic Zhang (CHINA)

Message: 82308   

 

OK. I see. It is 8250. Since we nevery run it on blackfin, I have no idea.

QuoteReplyEditDelete

 

 

2009-11-12 05:37:56     Re: quad uart

Sonic Zhang (CHINA)

Message: 82309   

 

Please check dmesg if your 8250 devices are probed properly.

QuoteReplyEditDelete

 

 

2009-11-12 05:52:19     Re: quad uart

Michael Hennerich (GERMANY)

Message: 82310    >

 

IIRC Schmid Engineering on their Zbrain BF533 - they use this driver successfully.

Based on your DCPLB posting - you must be using a plain old release.

 

I would update - and try again.

 

-Michael

QuoteReplyEditDelete

 

 

2009-11-12 07:53:40     Re: quad uart

Filip Vanalme (BELGIUM)

Message: 82316   

 

The only message related to serial device that I see with dmesg is :

 

Serial: 8250/16550 driver $Revision: 1.5 $ 4 ports, IRQ sharing disabled

 

I assume everything starts up correctly, otherwise I would expect error messages. So, I think probing should be OK.

TranslateQuoteReplyEditDelete

 

 

2009-11-12 08:13:08     Re: quad uart

Filip Vanalme (BELGIUM)

Message: 82317   

 

Indeed, we are using an old release : 2006R1. And changing to the most recent release is currently no option... hopefully, in the near future we can update to the latest release...

 

We used this serial configuration with the same release successfully in another project. The current project however, has a number of modifications with respect to that previous one : the address location of the uart is in another range and the uart was formarly a real uart-device, while now it is created in an fpga.

 

If I write at the same address location, directly from the application, I can see on a logic analyzer that the address, data and write enable are correct. However, when using the driver, the analyzer is not triggering at all : the device driver is not reading/writing at all to the address location, or, the device driver is reading/writing from the wrong address locations.

 

Because of that, I think it must have to do with configuration. Although I changed my ezkit file to match the address locations of the 4 uarts, I think there's still somewhere some configuration that has to be adjusted...

 

Filip

TranslateQuoteReplyEditDelete

 

 

2009-11-12 08:27:01     Re: quad uart

Michael Hennerich (GERMANY)

Message: 82318    Looks like you are using a BF561?

Does the driver do byte accesses?

I would check the 16-bit packing enable bits (B0PEN, B1PEN, B2PEN and B3PEN)

In the EBIU_AMGCTL register.

 

-Michael

QuoteReplyEditDelete

 

 

2009-11-12 10:40:26     Re: quad uart

Javier Herrero (SPAIN)

Message: 82319   

 

Hello,

 

You should see something more like this:

 

dma_alloc_init: dma_page @ 0x01eac000 - 256 pages at 0x01f00000

Serial: 8250/16550 driver4 ports, IRQ sharing enabled

serial8250.0: ttyS0 at MMIO 0x20200000 (irq = 41) is a 16550A

Serial: Blackfin serial driver

bfin-uart.1: ttyBF0 at MMIO 0xffc00400 (irq = 21) is a BFIN-UART

brd: module loaded

 

 

It seems that your UART is not probed right, perhaps it is a hardware problem or perhaps the UART flavour that you are using is not correctly detected by the driver. The driver tries to check several (in fact a lot) 16550-style UARTS.

 

Regards,

 

Javier

QuoteReplyEditDelete

 

 

2009-11-12 10:42:23     Re: quad uart

Filip Vanalme (BELGIUM)

Message: 82321   

 

I added some debug information in the kernel, in the modules that I think are involved in the serial communication i.e. serial_core.c and 8250.c. This is the console output I get when I do a sequence of open, write and close (blue is kernel output) :

 

Open /dev/ttyS0

uart_open(0) called

uart_open

/dev/ttyS0 open

Error [-1] : Input/output error (5)

uart_close(0) called

uart_flush_buffer(0) called

 

This is almost what I expected to see, except for the write. I put a message in front of that function, even before any check, and that message is never printed. It looks like it never comes in the uart_write() function at all and returns with an error even before arriving there. Am I right ? And what could hold me from accessing the write function if the open was successfull ?

 

 

 

Filip

TranslateQuoteReplyEditDelete

 

 

2009-11-12 11:00:17     Re: quad uart

Filip Vanalme (BELGIUM)

Message: 82322   

 

That's a good indication. I started our previous project (which succeeded with the same drivers...) and checked the startup sequence, and as you mentioned, I see more information coming there :

 

Serial: 8250/16550 driver $Revision: 1.5 $ 4 ports, IRQ sharing disabled

serial8250.0: ttyS0 at MMIO 0x28000070 (irq = 85) is a 16550A

serial8250.0: ttyS1 at MMIO 0x280000b0 (irq = 79) is a 16550A

serial8250.0: ttyS2 at MMIO 0x280000d0 (irq = 80) is a 16550A

serial8250.0: ttyS3 at MMIO 0x280000e0 (irq = 81) is a 16550A

 

So that should be a good starting point to look for the problem....

 

Filip

TranslateQuoteReplyEditDelete

 

 

2009-11-12 11:07:48     Re: quad uart

Javier Herrero (SPAIN)

Message: 82323   

 

I forgot to mention, this is working OK in 2009R1, I've not tested it lately in trunk. The hardware is our H8606 board, with FPGA implemented UARTs, you can see the platform code under arch/blackin/mach-bf533/boards/H8606.c

 

Regards,

 

Javier

Attachments

    Outcomes