Re: How to add uart driver for /dev/ttyS1

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

 



vichy wrote:
2009/7/14, Martyn Welch <martyn.welch@xxxxxxxxxxx>:
vichy wrote:

2009/7/14, Martyn Welch <martyn.welch@xxxxxxxxxxx>:

vichy wrote:


Dear all:
while tracing 8250.c, serial8250_init, I find all the ports are
assigned with the same uart_driver 8250 as below:
static struct uart_driver serial8250_reg = {
      .owner                  = THIS_MODULE,
      .driver_name            = "serial",
      .dev_name               = "ttyS",
      .major                  = TTY_MAJOR,
      .minor                  = 64,
      .nr                     = UART_NR,
      .cons                   = SERIAL8250_CONSOLE,
};

what make me curious is the minor# above is 64, but the minor number
of /dev/ttyS1 is 65.



 Numbering starts at 0, the first serial port (/dev/ttyS0) is assigned
minor
64.

hi:
Thanks for your reminding.
What makes me curious is how kernel connect /dev/ttyS1 with serial driver?
By port number or minor number?

I can see the minor of /dev/ttyS0 is 64, and serial driver is also
register as minor 64.
But what about /dev/ttyS1?

 Ah, I think I understand. The above structure is related to the 8250
driver, which is shared by all of the serial ports conforming to the "8250
type" of serial port.

 Looking at serial8250_register_port()
(http://lxr.linux.no/linux+v2.6.30/drivers/serial/8250.c#L3075),
which seems to be where individual ports are registered, there is an array
of type "uart_8250_port"
(http://lxr.linux.no/linux+v2.6.30/drivers/serial/8250.c#L2632)
which holds data pertaining to a specific port, which is then registered
with the serial core
(http://lxr.linux.no/linux+v2.6.30/drivers/serial/8250.c#L3116).
Hi:
thanks for your help.
I have 2 8250 serial devices.
and I want /dev/S1 to use the second 8250 device.
Should I
1. registering 2 ports in kernel and kernel will connect it to
/dev/ttyS1 automatically.
2. Or call 8250_init twice with and register uart_driver with minor number = 65?

if 1 is correct, can I boldly say the minor number of tty driver is meaningless?
if 2 is correct, what is the correct dev node we should create in /dev
about port2?

How are these serial ports connected? If the board you are working with is a standard PC, then the ports should be automatically discovered. It would appear that the function that probes for the standard serial ports is serial8250_isa_init_ports() (http://lxr.linux.no/linux+v2.6.30/drivers/serial/8250.c#L2634). If the serial ports are provided by a PCI device, then compile in or load 8250_pci.c as a module (http://lxr.linux.no/linux+v2.6.30/drivers/serial/8250_pci.c). If neither of these applies then I can only suggest looking at how similar boards already supported by the Linux kernel do it.

I think it might be worth you reading a bit of "Linux Device Drivers" (http://lwn.net/Kernel/LDD3/) if you think that the minor numbers are meaningless - they aren't.

If you are using an userspace environment with udev properly configured, you shouldn't need to worry about creating dev entries, they should be created automatically. If not, you need to create a dev entry with major number 4 and minor number 65. You can call it what you like, however the standard name would be "ttyS1".

Martyn
appreciate your help,
vichy


--
Martyn Welch MEng MPhil MIET (Principal Software Engineer)   T:+44(0)1327322748
GE Fanuc Intelligent Platforms Ltd,        |Registered in England and Wales
Tove Valley Business Park, Towcester,      |(3828642) at 100 Barbirolli Square,
Northants, NN12 6PF, UK T:+44(0)1327359444 |Manchester,M2 3AB  VAT:GB 927559189

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux