is there a struct uart_driver like struct i2c_driver
Hey,
I need to write a driver which communicates with it's chip via uart. So I was wondering which the best way is to do this.
For a i2c device there is the i2c subsystem with it's "module_i2c_driver(foo_driver);" and so on. But I couldn't find any equivalent for a uart device.
So what is the desired way to implement such a driver? Is there one or do I need to "struct file * f = filp_open("/dev/ttyS4", FLAGS, MODE);" ?
Thanks any hint!
Cheers,
Thilo
Quoted 8 lines · Cestonaro Thilo
Hey,
I need to write a driver which communicates with it's chip via uart. So I was wondering which the best way is to do this.
For a i2c device there is the i2c subsystem with it's "
module_i2c_driver(foo_driver);" and so on. But I couldn't find any equivalent for a uart device.
Did you see include/linux/serial_core.h ?
Thx Greg. This one I missed!
But it's what I searched for.
Cheers,
Thilo
Quoted 11 lines · Greg KH
Quoted 8 lines · Cestonaro Thilo
Hey,
I need to write a driver which communicates with it's chip via uart. So I was wondering which the best way is to do this.
For a i2c device there is the i2c subsystem with it's "
module_i2c_driver(foo_driver);" and so on. But I couldn't find any equivalent for a uart device.Did you see
include/linux/serial_core.h?
Signature · 16 lines
With best regards Thilo Cestonaro FTS PSO PM&D CCD E EPC Fujitsu Technology Solutions GmbH Buergermeister-Ulrich-Str. 100 86199 Augsburg Germany Tel.: +49 (0)821 804 2328 Fax: +49 (0)821 804 82328 E-mail: [email protected] Web: http://ts.fujitsu.com Company details: http://ts.fujitsu.com/imprint
Hmm or not :( ... at a first glance it was.
But this is for a driver which implements the UART support but I want to use the UART but not implement it's hw support.
As a i2c_module doesn't implement the i2c controller support but uses it.
Or do I miss something?
Cheers,
Thilo
Quoted 21 lines · Cestonaro Thilo
Thx Greg. This one I missed!
But it's what I searched for.
Cheers,
ThiloQuoted 11 lines · Greg KH
Quoted 8 lines · Cestonaro Thilo
Hey,
I need to write a driver which communicates with it's chip via uart. So I was wondering which the best way is to do this.
For a i2c device there is the i2c subsystem with it's "
module_i2c_driver(foo_driver);" and so on. But I couldn't find any equivalent for a uart device.Did you see
include/linux/serial_core.h?
Signature · 16 lines
With best regards Thilo Cestonaro FTS PSO PM&D CCD E EPC Fujitsu Technology Solutions GmbH Buergermeister-Ulrich-Str. 100 86199 Augsburg Germany Tel.: +49 (0)821 804 2328 Fax: +49 (0)821 804 82328 E-mail: [email protected] Web: http://ts.fujitsu.com Company details: http://ts.fujitsu.com/imprint
Hey,
do I need to do something like:
----
f = filp_open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY, 0600); fs=get_fs();set_fs(KERNEL_DS);
---
Is there really no API for a uart attached device to communicate with it?
That would be the last thing I thought of :(.
Cheers,
Thilo
Quoted 35 lines · Cestonaro Thilo
Hmm or not :( ... at a first glance it was.
But this is for a driver which implements the UART support but I want to use the UART but not implement it's hw support.
As a
i2c_moduledoesn't implement the i2c controller support but uses it.Or do I miss something?
Cheers,
ThiloQuoted 21 lines · Cestonaro Thilo
Thx Greg. This one I missed!
But it's what I searched for.
Cheers,
ThiloQuoted 11 lines · Greg KH
Quoted 8 lines · Cestonaro Thilo
Hey,
I need to write a driver which communicates with it's chip via uart. So I was wondering which the best way is to do this.
For a i2c device there is the i2c subsystem with it's "
module_i2c_driver(foo_driver);" and so on. But I couldn't find any equivalent for a uart device.Did you see
include/linux/serial_core.h?
Signature · 16 lines
With best regards Thilo Cestonaro FTS PSO PM&D CCD E EPC Fujitsu Technology Solutions GmbH Buergermeister-Ulrich-Str. 100 86199 Augsburg Germany Tel.: +49 (0)821 804 2328 Fax: +49 (0)821 804 82328 E-mail: [email protected] Web: http://ts.fujitsu.com Company details: http://ts.fujitsu.com/imprint
Quoted 11 lines · Cestonaro Thilo
Hey,
do I need to do something like:
----
f =filp_open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY, 0600); fs=get_fs();set_fs(KERNEL_DS);
---
Is there really no API for a uart attached device to communicate with it?That would be the last thing I thought of :(.
Wait, you want to talk to a serial port from within the kernel? No, don't open the device node, just talk directly to the tty layer. An example of code that does this is some of the bluetooth layer.
good luck,
greg k-h
Quoted 11 lines · Greg KH
Quoted 10 lines · Cestonaro Thilo
Hey,
do I need to do something like:
----
f =filp_open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY, 0600); fs=get_fs();set_fs(KERNEL_DS);
---
Is there really no API for a uart attached device to communicate with it?
Quoted 9 lines
Quoted 1 line
That would be the last thing I thought of :(.
Wait, you want to talk to a serial port from within the kernel? No, don't open the device node, just talk directly to the tty layer. An example of code that does this is some of the bluetooth layer.
good luck,
greg k-h
From the hci_uart stuff I got to the conclusion that I need to implement a tty line discipline driver and change the corresponding tty's line discipline to my own one.
Is this the best way or did I miss something? I ask again, cause writing a tty line discipline looks rather complicate then straight forward and before I start doing it,
I want to be sure to not run against a wall :).
Cheers,
Thilo
Quoted 27 lines · Cestonaro Thilo
Quoted 11 lines · Greg KH
Quoted 10 lines · Cestonaro Thilo
Hey,
do I need to do something like:
----
f =filp_open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY, 0600); fs=get_fs();set_fs(KERNEL_DS);
---
Is there really no API for a uart attached device to communicate with it?Quoted 9 lines
Quoted 1 line
That would be the last thing I thought of :(.
Wait, you want to talk to a serial port from within the kernel? No, don't open the device node, just talk directly to the tty layer. An example of code that does this is some of the bluetooth layer.
good luck,
greg k-h
From the
hci_uartstuff I got to the conclusion that I need to implement a tty line discipline driver and change the corresponding tty's line discipline
to my own one.
Quoted 4 lines
Is this the best way or did I miss something? I ask again, cause writing a tty line discipline
looks rather complicate then straight forward and before I start doing it, I want to be sure to not run against a wall :).
You might want to step back and describe what you are wanting to do in the first place before wanting to add a new line discipline.
thanks,
greg k-h
Quoted 2 lines · Cestonaro Thilo
I need to write a driver which communicates with it's chip via uart. So I was wondering which the best way is to do this.
What I think you're talking about is usually called a "line discipline":
http://www.linux-mag.com/id/1891/
http://en.wikipedia.org/wiki/Line_discipline
http://www.linux.it/~rubini/docs/serial/serial.html
[Some of those links are a bit out-of-date, but should provide a good idea what a line discipline is.]
Line disciplines are kernel drivers that use a well-defined API to talk to the tty/serial/uart drivers that exist at a lower layer.
Signature · 3 lines
Grant Edwards grant.b.edwards Yow! MERYL STREEP is my
at obstetrician!
gmail.com Quoted 4 lines
You might want to step back and describe what you are wanting to do in the first place before wanting to add a new line discipline.
Ok.
Imagine you have two chips, one is the cpu and the other one is a device which needs to be configured, accessed, talked to via uart. The both chips are hardwired via uart.
Now I want to communicate from the kernel module with the device. let the device be a RTC Device which has a UART interface.
And I don't want to rewrite all the uart device stuff of the cpu uart device.
As a i2c client doesn't implement master_xfer or whatever the transfer methods are called in the i2c controller module.
It just does a i2c->write(reg, value) and I need something equivalent like uart->send(data, len); and uart->handle_recieved = my_recieved_data_handler;
Something like that.
Hope this explains it better!
As far as I currently understood, this would be a line discipline.
Cheers,
Thilo
Signature · 16 lines
With best regards Thilo Cestonaro FTS PSO PM&D CCD E EPC Fujitsu Technology Solutions GmbH Buergermeister-Ulrich-Str. 100 86199 Augsburg Germany Tel.: +49 (0)821 804 2328 Fax: +49 (0)821 804 82328 E-mail: [email protected] Web: http://ts.fujitsu.com Company details: http://ts.fujitsu.com/imprint
Quoted 9 lines · Cestonaro Thilo
Quoted 4 lines
You might want to step back and describe what you are wanting to do in the first place before wanting to add a new line discipline.
Ok.
Imagine you have two chips, one is the cpu and the other one is a device which needs to be configured, accessed, talked to via uart. The both chips are hardwired via uart.
Now I want to communicate from the kernel module with the device.
Why within the kernel? Why not do the communication from userspace?
Quoted 1 line
let the device be a RTC Device which has a UART interface.
How do you talk to this UART? Through a "normal" serial chip that the kernel already has a driver for, or through some other hardware control interface?
Quoted 2 lines
And I don't want to rewrite all the uart device stuff of the cpu uart device.
What do you mean by this?
Quoted 5 lines
As a i2c client doesn't implement
master_xferor whatever the transfer methods are called in the i2c controller module.
It just does ai2c->write(reg, value)and I need something equivalent likeuart->send(data, len); anduart->handle_recieved=my_recieved_data_handler;
Do that in userspace :)
thanks,
greg k-h
Quoted 11 lines · Greg KH
Quoted 9 lines · Cestonaro Thilo
Quoted 4 lines
You might want to step back and describe what you are wanting to do in the first place before wanting to add a new line discipline.
Ok.
Imagine you have two chips, one is the cpu and the other one is a device which needs to be configured, accessed, talked to via uart. The both chips are hardwired via uart.
Now I want to communicate from the kernel module with the device.Why within the kernel? Why not do the communication from userspace?
Cause it's a rtc, and I don't know of a way to have a /dev/rtc from userspace
Quoted 5 lines
Quoted 2 lines
let the device be a RTC Device which has a UART interface.
How do you talk to this UART? Through a "normal" serial chip that the kernel already has a driver for, or through some other hardware control interface?
Jup, via normal serial chip.
Quoted 4 lines
Quoted 3 lines
And I don't want to rewrite all the uart device stuff of the cpu uart device.
What do you mean by this?
As it is via a normal serial chip, one option would be to write a sperate driver which includes all the register stuff from the original serial chip module.
But this, I don't want to do.
Quoted 7 lines
Quoted 6 lines
As a i2c client doesn't implement
master_xferor whatever the transfer methods are called in the i2c controller module.
It just does ai2c->write(reg, value)and I need something equivalent likeuart->send(data, len); anduart->handle_recieved=my_recieved_data_handler;Do that in userspace :)
Is there a way to have a HW Clock support from userland?
Quoted 5 lines
thanks,
greg k-h
Signature · 16 lines
With best regards Thilo Cestonaro FTS PSO PM&D CCD E EPC Fujitsu Technology Solutions GmbH Buergermeister-Ulrich-Str. 100 86199 Augsburg Germany Tel.: +49 (0)821 804 2328 Fax: +49 (0)821 804 82328 E-mail: [email protected] Web: http://ts.fujitsu.com Company details: http://ts.fujitsu.com/imprint
Quoted 23 lines · Cestonaro Thilo
Quoted 11 lines · Greg KH
Quoted 9 lines · Cestonaro Thilo
Quoted 4 lines
You might want to step back and describe what you are wanting to do in the first place before wanting to add a new line discipline.
Ok.
Imagine you have two chips, one is the cpu and the other one is a device which needs to be configured, accessed, talked to via uart. The both chips are hardwired via uart.
Now I want to communicate from the kernel module with the device.Why within the kernel? Why not do the communication from userspace?
Cause it's a rtc, and I don't know of a way to have a
/dev/rtcfrom userspaceQuoted 5 lines
Quoted 2 lines
let the device be a RTC Device which has a UART interface.
How do you talk to this UART? Through a "normal" serial chip that the kernel already has a driver for, or through some other hardware control interface?
Jup, via normal serial chip.
Quoted 1 line
Quoted 7 lines
Quoted 3 lines
Quoted 2 lines
And I don't want to rewrite all the uart device stuff of the cpu uart device.
What do you mean by this?
As it is via a normal serial chip, one option would be to write a sperate driver which includes all the register stuff from the original serial chip module.
But this, I don't want to do.
Try using the serio interface, it should do this all for you.
greg k-h