Atmel website | ARM Community | AVR freaks | Technical Support
Banner
 FAQ •  Search •  Register •  Login 

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: AT91sam9 external serial 8250/16550
PostPosted: Mon May 16, 2011 3:30 am 
Offline

Joined: Sun Apr 17, 2011 5:44 pm
Posts: 11
I'm trying put two external serial to work in our board is based on at91sam9g45 and was used an TL16C2550 with two UART.

Those ports are selected by CSA and CSB which are connected to SR_NCS1 and NCS2 respectively.

This device is found at boot time:

Serial: 8250/16550 driver, 4 ports, IRQ sharing disabled
serial8250.1: ttyS0 at MMIO 0x30000000 (irq = 97) is a 16550A

but I was waiting for first serial on 0x20000000 how defined in struct plat_serial8250_port:

#define SERIAL_FLAGS (UPF_BOOT_AUTOCONF | UPF_IOREMAP| UPF_SHARE_IRQ)
#define SERIAL_CLK (11059200)

static struct plat_serial8250_port tms_uart_data[] = {
[0] = {
.mapbase = AT91_CHIPSELECT_1,
.irq = AT91_PIN_PC0,
.uartclk = SERIAL_CLK,
.iotype = UPIO_MEM,
.regshift = 0,
.flags = SERIAL_FLAGS,
},
[1] = {
.mapbase = AT91_CHIPSELECT_2,
.irq = AT91_PIN_PC1,
.uartclk = SERIAL_CLK,
.iotype = UPIO_MEM,
.regshift = 0,
.flags = SERIAL_FLAGS,
},
{ }
};

Why only one port is detected? Are there any especial programming for SR_NCS1 work?

Only one serial is detected but doesn't work properly yet.


Top
 Profile  
 
 Post subject: Re: AT91sam9 external serial 8250/16550
PostPosted: Tue Aug 16, 2011 8:16 am 
Offline

Joined: Mon Jan 17, 2011 11:17 am
Posts: 13
sorry, i can not help you, for I meet some issues on adding 16c554 for 9261s.
can you please give me some advice?
do you only modify 8250_exar_st16c554.c?
here is my program i designed in 8250_exar_st16c554.c, but it can not work, (now I just test the kernel, and my ev-board has not 16c554 chip, I don't know whether it is the reason of these errors.)

#define PORT(_base,_irq) \
{ \
.mapbase = (unsigned long)_base, \
.irq = (unsigned int)_irq, \
.uartclk = 1843200, \
.iotype = UPIO_MEM, \
.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
.regshift = 0, \
}

static struct plat_serial8250_port exar_data[] = {
PORT(AT91_CHIPSELECT_0+0x100, AT91_PIN_PB30),
PORT(AT91_CHIPSELECT_0+0x108, AT91_PIN_PB30),
PORT(AT91_CHIPSELECT_0+0x110, AT91_PIN_PB30),
PORT(AT91_CHIPSELECT_0+0x118, AT91_PIN_PB30),
{ },
};

but after boot kernel, some errors display:
VFS: Mounted root (nfs filesystem) on device 0:12.
Freeing init memory: 140K
Unable to handle kernel NULL pointer dereference at virtual address 00000000
pgd = c0004000
[00000000] *pgd=00000000
Internal error: Oops: 5 [#1]
Modules linked in:
CPU: 0 Not tainted (2.6.30 #74)
PC is at tty_open+0x18c/0x400
LR is at tty_open+0xf4/0x400
pc : [<c018dbb8>] lr : [<c018db20>] psr: 60000013
sp : c3817e4c ip : c3817e4c fp : c3817e7c
r10: 00500001 r9 : c340ba2c r8 : 00000001
r7 : 00000000 r6 : c387e7c0 r5 : 00000000 r4 : c3a96780
r3 : 00000000 r2 : 00000000 r1 : 0000002b r0 : c03ac974
Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel
Control: 0005317f Table: 20004000 DAC: 00000017
Process swapper (pid: 1, stack limit = 0xc3816260)
Stack: (0xc3817e4c to 0xc3818000)


Top
 Profile  
 
 Post subject: Re: AT91sam9 external serial 8250/16550
PostPosted: Tue Aug 16, 2011 1:40 pm 
Offline

Joined: Sun Apr 17, 2011 5:44 pm
Posts: 11
No modifications was made in 8250* kernel files.

Our problem here was one line of chip select which was set up at bootstrap incorrectly. To override this we made this setup:

/* NCS2 */
at91_set_A_periph(AT91_PIN_PC13,0);

Our struct plat_serial8250_port is in this way:

#define SERIAL_FLAGS (UPF_BOOT_AUTOCONF | UPF_IOREMAP | UPF_SHARE_IRQ)

static struct plat_serial8250_port tms_uart_data[] = {
[0] = {
.mapbase = AT91_CHIPSELECT_1,
.irq = AT91_PIN_PC0,
.uartclk = SERIAL_CLK,
.iotype = UPIO_MEM,
.regshift = 0,
.flags = SERIAL_FLAGS,
},
[1] = {
.mapbase = AT91_CHIPSELECT_2,
.irq = AT91_PIN_PC1,
.uartclk = SERIAL_CLK,
.iotype = UPIO_MEM,
.regshift = 0,
.flags = SERIAL_FLAGS,
},
{ }
};


Top
 Profile  
 
 Post subject: Re: AT91sam9 external serial 8250/16550
PostPosted: Tue Aug 16, 2011 2:28 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
Look at the source code for tty_open, about 38% into the routine, and see what pointer is not being initialized.

Also, validate the hardware outside of Linux, and confirm it works properly, and that you have configured the PIO's, chip selects, etc correctly.


Top
 Profile  
 
 Post subject: Re: AT91sam9 external serial 8250/16550
PostPosted: Wed Aug 17, 2011 12:01 pm 
Offline

Joined: Mon Jan 17, 2011 11:17 am
Posts: 13
CptTitanic,
thanks for your advices. For now I has not finished my PCB design, I can not confirm this error is because of 16c554 chip's missing.
I am designing PCB now, and I will test it again on the new board with this chip.

halliday,
Have you solved your problem? congrarulation!
If you have not solved it, here is the 8250_..._st16c554.c I copied from internet, I hope it is helpful for you.

#include <linux/module.h>
#include <linux/init.h>
#include <linux/serial_8250.h>
#include <mach/gpio.h>
#include <mach/at91sam9_smc.h>
#include <../sam9_smc.h>

#define XR16V554_BASE1 (AT91_CHIPSELECT_2 + 0X00) //Base address of USART0
#define XR16V554_BASE2 (AT91_CHIPSELECT_2 + 0X08)
#define XR16V554_BASE3 (AT91_CHIPSELECT_2 + 0X10)
#define XR16V554_BASE4 (AT91_CHIPSELECT_2 + 0X18)

#define XR16V554_IRQ1 AT91_PIN_PB19
#define XR16V554_IRQ2 AT91_PIN_PB20
#define XR16V554_IRQ3 AT91_PIN_PB21
#define XR16V554_IRQ4 AT91_PIN_PB22

/* Tuned for MCLK=100MHZ also applied for MCLK=133MHZ */
static struct sam9_smc_config __initdata ek_xr16v554_smc_config = {
.ncs_read_setup = 0,
.nrd_setup = 2,
.ncs_write_setup = 0,
.nwe_setup = 2,

.ncs_read_pulse = 16, /* min 40ns */
.nrd_pulse = 12, /* min 40ns */
.ncs_write_pulse = 16,
.nwe_pulse = 12,

.read_cycle = 18,
.write_cycle = 18,

.mode = AT91_SMC_READMODE | AT91_SMC_WRITEMODE | AT91_SMC_EXNWMODE_DISABLE | AT91_SMC_DBW_8,
.tdf_cycles = 10,
};


#define PORT(_base,_irq) \
{ \
.mapbase = _base, \
.irq = _irq, \
.uartclk = 7372800, \
.iotype = UPIO_MEM, \
.regshift = 0, \
.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP,\
}

static struct plat_serial8250_port exar_data[] = {
PORT(XR16V554_BASE1, XR16V554_IRQ1),
PORT(XR16V554_BASE2, XR16V554_IRQ2),
PORT(XR16V554_BASE3, XR16V554_IRQ3),
PORT(XR16V554_BASE4, XR16V554_IRQ4),
{ },
};

static struct platform_device exar_device = {
.name = "serial8250",
.id = PLAT8250_DEV_AT91_XR16V554,
.dev = {
.platform_data = &exar_data,
},
};

static int __init exar_init(void)
{
/* Set the inerrupt pin to gpio and enable pullup. */
at91_set_GPIO_periph(AT91_PIN_PB19, 1);
at91_set_GPIO_periph(AT91_PIN_PB20, 1);
at91_set_GPIO_periph(AT91_PIN_PB21, 1);
at91_set_GPIO_periph(AT91_PIN_PB22, 1);

/* Enable input and pullup. */
at91_set_gpio_input(AT91_PIN_PB19, 1);
at91_set_gpio_input(AT91_PIN_PB20, 1);
at91_set_gpio_input(AT91_PIN_PB21, 1);
at91_set_gpio_input(AT91_PIN_PB22, 1);

/* Enable glitch. */
at91_set_deglitch(AT91_PIN_PB19, 1);
at91_set_deglitch(AT91_PIN_PB20, 1);
at91_set_deglitch(AT91_PIN_PB21, 1);
at91_set_deglitch(AT91_PIN_PB22, 1);

/* Set up the 8-bit bus */
/* configure chip-select 2 (XR16V554D) */
sam9_smc_configure(2, &ek_xr16v554_smc_config);

printk("8250_at91_xr16v554 device register!\n");

return platform_device_register(&exar_device);
}

module_init(exar_init);


Top
 Profile  
 
 Post subject: Re: AT91sam9 external serial 8250/16550
PostPosted: Wed Aug 17, 2011 12:08 pm 
Offline

Joined: Mon Jan 17, 2011 11:17 am
Posts: 13
[quote="CptTitanic"]Look at the source code for tty_open, about 38% into the routine, and see what pointer is not being initialized.

Also, validate the hardware outside of Linux, and confirm it works properly, and that you have configured the PIO's, chip selects, etc correctly.[/quote]
CptTitanic ,
Like halliday said, he did not modify 8250's kernel file, so I think the reasons of my errors is:
1, 16c554 chip missing,
2, errors in 8250_at91_16c554.c, but this file is very simple, I almost tested every item.
here is my 8250_at91_16c554.c file:
#include <linux/module.h>
#include <linux/init.h>
#include <linux/serial_8250.h>

#include <mach/gpio.h>
#include <mach/at91sam9_smc.h>
#include <../sam9_smc.h>

static struct sam9_smc_config __initdata ek_exar_smc_config = {
...(setting at91's smc timeing) ...
};
//here .mapbase, i tried resource_size_t, too, same result.
//UPIO_MEM32 was tested, too, same result.
#define PORT(_base,_irq) \
{ \
.mapbase = (unsigned long)_base, \
.irq = _irq, \
.uartclk = 1843200, \
.iotype = UPIO_MEM, \
.flags = UPF_BOOT_AUTOCONF | UPF_IOREMAP, \
.regshift = 0, \
}
static struct plat_serial8250_port exar_data[] = {
PORT(AT91_CHIPSELECT_0+0x100, AT91_PIN_PB30),
PORT(AT91_CHIPSELECT_0+0x108, AT91_PIN_PB30),
PORT(AT91_CHIPSELECT_0+0x110, AT91_PIN_PB30),
PORT(AT91_CHIPSELECT_0+0x118, AT91_PIN_PB30),
{ },
};
static struct platform_device exar_device = {
.name = "serial8250",
.id = PLAT8250_DEV_AT91_ST16C554,
.dev = {
.platform_data = &exar_data,
},
};
static int __init exar_init(void)
{
/* Configure Interrupt pin as input, no pull-up */
at91_set_gpio_input(AT91_PIN_PB30, 0);
/* configure chipselect 0 (exar 16c554 */
sam9_smc_configure(0,&ek_exar_smc_config);

/* configure chipselect 0 (exar 16c554 */
sam9_smc_configure(0,&ek_exar_smc_config);
printk("8250_at91_16c554 device register!!!\n");
return platform_device_register(&exar_device);
}
module_init(exar_init);
MODULE_AUTHOR("Paul B Schroeder");
MODULE_DESCRIPTION("8250 serial probe module for Exar cards");
MODULE_LICENSE("GPL");

I don't know how to use backtrace to find out the issues.
can you please help to tell me how to do it?


Top
 Profile  
 
 Post subject: Re: AT91sam9 external serial 8250/16550
PostPosted: Wed Aug 17, 2011 4:28 pm 
Offline

Joined: Sat Oct 30, 2010 6:04 pm
Posts: 574
Even without the physical chip, one can write code that runs on the chip, and verifiy chip select signals do what you expect, with either an oscilloscope or logic analyzer.

>>I don't know how to use backtrace to find out the issues. can you please help to tell me how to do it?

Start at the beginning of the failure, most of the trailing data is supplemental and might only help in specific conditions. Focus on the fault, and look at what the source is doing.

It's complaining about a NULL pointer, it's loading a pointer with zero, and then accessing it.
It points you at a specific piece of code. foo()+0xAAAA/0xBBBB the first offset is a byte location within the routine, the second is the size of the routine, you can use this to estimate a position/line within the routine.
You might be able to walk back the call chain to figure how/why it got there, or consider why the port initialization may have failed, or why critical structures were not set up. One might assume the initialization errored, but didn't clean up after itself properly, and subsequent code didn't propagate the error, or sanity check the pointers.
You'll likely have to did into the kernel and get you hands dirty.


Top
 Profile  
 
 Post subject: Re: AT91sam9 external serial 8250/16550
PostPosted: Thu Aug 18, 2011 2:36 am 
Offline

Joined: Mon Jan 17, 2011 11:17 am
Posts: 13
CptTitanic,
thanks! I learned a lot.
I will try and update it.


Top
 Profile  
 
 Post subject: Re: AT91sam9 external serial 8250/16550
PostPosted: Fri Oct 14, 2011 8:47 am 
Offline

Joined: Fri May 11, 2007 12:01 pm
Posts: 1
Dear halliday, demoxie, CptTitanic and others,

I have plan to add 4 additional UARTs into the Linux system based on the AT91SAM9 MCU.

1. Can somebody give me some hints how to connect one of the TL16C2550, 16C554, 16C654 UARTs? Of course full solution or partial (part of schematic and Linux driver) will be very appreciated.

2. Does it required to connect all interrupt and CS lines to individual pins of MCU or some of them can be shared?

3. As I understand, it is required to add a new driver like a 8250_accent.c or 8250_exar_st16c554.c? But what is confusing for me is that AT91SAM9 does not use port accesses to devices connected through SMC - it uses MMIO. How to deal with this in the driver?

Best regards!
--
Igor Plyatov


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 9 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: Bing [Bot] and 4 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: