* is there a struct uart_driver like struct i2c_driver
@ 2014-08-18 9:54 Cestonaro Thilo
2014-08-18 10:53 ` Greg KH
2014-08-18 16:19 ` Grant Edwards
0 siblings, 2 replies; 13+ messages in thread
From: Cestonaro Thilo @ 2014-08-18 9:54 UTC (permalink / raw)
To: linux-serial@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 479 bytes --]
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
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 2798 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: is there a struct uart_driver like struct i2c_driver
2014-08-18 9:54 is there a struct uart_driver like struct i2c_driver Cestonaro Thilo
@ 2014-08-18 10:53 ` Greg KH
2014-08-18 11:11 ` Cestonaro Thilo
2014-08-18 16:19 ` Grant Edwards
1 sibling, 1 reply; 13+ messages in thread
From: Greg KH @ 2014-08-18 10:53 UTC (permalink / raw)
To: Cestonaro Thilo; +Cc: linux-serial@vger.kernel.org
On Mon, Aug 18, 2014 at 11:54:48AM +0200, Cestonaro Thilo wrote:
> 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 ?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: is there a struct uart_driver like struct i2c_driver
2014-08-18 10:53 ` Greg KH
@ 2014-08-18 11:11 ` Cestonaro Thilo
2014-08-18 11:19 ` Cestonaro Thilo
0 siblings, 1 reply; 13+ messages in thread
From: Cestonaro Thilo @ 2014-08-18 11:11 UTC (permalink / raw)
To: Greg KH; +Cc: linux-serial@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 890 bytes --]
Thx Greg. This one I missed!
But it's what I searched for.
Cheers,
Thilo
On 18.08.2014 12:53, Greg KH wrote:
> On Mon, Aug 18, 2014 at 11:54:48AM +0200, Cestonaro Thilo wrote:
>> 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 ?
>
--
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: thilo.cestonaro@ts.fujitsu.com
Web: http://ts.fujitsu.com
Company details: http://ts.fujitsu.com/imprint
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 2798 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: is there a struct uart_driver like struct i2c_driver
2014-08-18 11:11 ` Cestonaro Thilo
@ 2014-08-18 11:19 ` Cestonaro Thilo
2014-08-18 13:43 ` Cestonaro Thilo
0 siblings, 1 reply; 13+ messages in thread
From: Cestonaro Thilo @ 2014-08-18 11:19 UTC (permalink / raw)
To: Greg KH; +Cc: linux-serial@vger.kernel.org
[-- Attachment #1: Type: text/plain, Size: 1260 bytes --]
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
On 18.08.2014 13:11, Cestonaro Thilo wrote:
> Thx Greg. This one I missed!
>
> But it's what I searched for.
>
> Cheers,
> Thilo
>
> On 18.08.2014 12:53, Greg KH wrote:
>> On Mon, Aug 18, 2014 at 11:54:48AM +0200, Cestonaro Thilo wrote:
>>> 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 ?
>>
>
>
--
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: thilo.cestonaro@ts.fujitsu.com
Web: http://ts.fujitsu.com
Company details: http://ts.fujitsu.com/imprint
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 2798 bytes --]
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: is there a struct uart_driver like struct i2c_driver
2014-08-18 11:19 ` Cestonaro Thilo
@ 2014-08-18 13:43 ` Cestonaro Thilo
2014-08-18 13:50 ` Greg KH
0 siblings, 1 reply; 13+ messages in thread
From: Cestonaro Thilo @ 2014-08-18 13:43 UTC (permalink / raw)
To: linux-serial@vger.kernel.org
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
On 18.08.2014 13:19, Cestonaro Thilo wrote:
> 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
>
> On 18.08.2014 13:11, Cestonaro Thilo wrote:
>> Thx Greg. This one I missed!
>>
>> But it's what I searched for.
>>
>> Cheers,
>> Thilo
>>
>> On 18.08.2014 12:53, Greg KH wrote:
>>> On Mon, Aug 18, 2014 at 11:54:48AM +0200, Cestonaro Thilo wrote:
>>>> 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 ?
>>>
>>
>>
>
>
--
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: thilo.cestonaro@ts.fujitsu.com
Web: http://ts.fujitsu.com
Company details: http://ts.fujitsu.com/imprint
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: is there a struct uart_driver like struct i2c_driver
2014-08-18 13:43 ` Cestonaro Thilo
@ 2014-08-18 13:50 ` Greg KH
2014-08-18 14:56 ` Cestonaro Thilo
0 siblings, 1 reply; 13+ messages in thread
From: Greg KH @ 2014-08-18 13:50 UTC (permalink / raw)
To: Cestonaro Thilo; +Cc: linux-serial@vger.kernel.org
On Mon, Aug 18, 2014 at 03:43:27PM +0200, Cestonaro Thilo wrote:
> 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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: is there a struct uart_driver like struct i2c_driver
2014-08-18 13:50 ` Greg KH
@ 2014-08-18 14:56 ` Cestonaro Thilo
2014-08-18 15:07 ` Greg KH
0 siblings, 1 reply; 13+ messages in thread
From: Cestonaro Thilo @ 2014-08-18 14:56 UTC (permalink / raw)
To: Greg KH; +Cc: linux-serial@vger.kernel.org
On 18.08.2014 15:50, Greg KH wrote:
> On Mon, Aug 18, 2014 at 03:43:27PM +0200, Cestonaro Thilo wrote:
>> 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
>
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: is there a struct uart_driver like struct i2c_driver
2014-08-18 14:56 ` Cestonaro Thilo
@ 2014-08-18 15:07 ` Greg KH
2014-08-19 12:25 ` Cestonaro Thilo
0 siblings, 1 reply; 13+ messages in thread
From: Greg KH @ 2014-08-18 15:07 UTC (permalink / raw)
To: Cestonaro Thilo; +Cc: linux-serial@vger.kernel.org
On Mon, Aug 18, 2014 at 04:56:24PM +0200, Cestonaro Thilo wrote:
> On 18.08.2014 15:50, Greg KH wrote:
> >On Mon, Aug 18, 2014 at 03:43:27PM +0200, Cestonaro Thilo wrote:
> >>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
> >
>
> 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 :).
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
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: is there a struct uart_driver like struct i2c_driver
2014-08-18 9:54 is there a struct uart_driver like struct i2c_driver Cestonaro Thilo
2014-08-18 10:53 ` Greg KH
@ 2014-08-18 16:19 ` Grant Edwards
1 sibling, 0 replies; 13+ messages in thread
From: Grant Edwards @ 2014-08-18 16:19 UTC (permalink / raw)
To: linux-serial
On 2014-08-18, Cestonaro Thilo <thilo.cestonaro@ts.fujitsu.com> wrote:
> 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.
--
Grant Edwards grant.b.edwards Yow! MERYL STREEP is my
at obstetrician!
gmail.com
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: is there a struct uart_driver like struct i2c_driver
2014-08-18 15:07 ` Greg KH
@ 2014-08-19 12:25 ` Cestonaro Thilo
2014-08-19 12:39 ` Greg KH
0 siblings, 1 reply; 13+ messages in thread
From: Cestonaro Thilo @ 2014-08-19 12:25 UTC (permalink / raw)
To: Greg KH; +Cc: linux-serial@vger.kernel.org
> 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
--
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: thilo.cestonaro@ts.fujitsu.com
Web: http://ts.fujitsu.com
Company details: http://ts.fujitsu.com/imprint
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: is there a struct uart_driver like struct i2c_driver
2014-08-19 12:25 ` Cestonaro Thilo
@ 2014-08-19 12:39 ` Greg KH
2014-08-19 12:45 ` Cestonaro Thilo
0 siblings, 1 reply; 13+ messages in thread
From: Greg KH @ 2014-08-19 12:39 UTC (permalink / raw)
To: Cestonaro Thilo; +Cc: linux-serial@vger.kernel.org
On Tue, Aug 19, 2014 at 02:25:57PM +0200, Cestonaro Thilo wrote:
> > 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?
> 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?
> And I don't want to rewrite all the uart device stuff of the cpu uart
> device.
What do you mean by this?
> 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;
Do that in userspace :)
thanks,
greg k-h
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: is there a struct uart_driver like struct i2c_driver
2014-08-19 12:39 ` Greg KH
@ 2014-08-19 12:45 ` Cestonaro Thilo
2014-08-25 14:57 ` Greg KH
0 siblings, 1 reply; 13+ messages in thread
From: Cestonaro Thilo @ 2014-08-19 12:45 UTC (permalink / raw)
To: Greg KH; +Cc: linux-serial@vger.kernel.org
On 19.08.2014 14:39, Greg KH wrote:
> On Tue, Aug 19, 2014 at 02:25:57PM +0200, Cestonaro Thilo wrote:
>>> 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
>
>> 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.
>
>> 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.
>
>> 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;
> Do that in userspace :)
Is there a way to have a HW Clock support from userland?
> thanks,
>
> greg k-h
>
>
--
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: thilo.cestonaro@ts.fujitsu.com
Web: http://ts.fujitsu.com
Company details: http://ts.fujitsu.com/imprint
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: is there a struct uart_driver like struct i2c_driver
2014-08-19 12:45 ` Cestonaro Thilo
@ 2014-08-25 14:57 ` Greg KH
0 siblings, 0 replies; 13+ messages in thread
From: Greg KH @ 2014-08-25 14:57 UTC (permalink / raw)
To: Cestonaro Thilo; +Cc: linux-serial@vger.kernel.org
On Tue, Aug 19, 2014 at 02:45:47PM +0200, Cestonaro Thilo wrote:
> On 19.08.2014 14:39, Greg KH wrote:
> > On Tue, Aug 19, 2014 at 02:25:57PM +0200, Cestonaro Thilo wrote:
> >>> 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
>
> >
> >> 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.
>
> >
> >> 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
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2014-08-25 14:57 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-18 9:54 is there a struct uart_driver like struct i2c_driver Cestonaro Thilo
2014-08-18 10:53 ` Greg KH
2014-08-18 11:11 ` Cestonaro Thilo
2014-08-18 11:19 ` Cestonaro Thilo
2014-08-18 13:43 ` Cestonaro Thilo
2014-08-18 13:50 ` Greg KH
2014-08-18 14:56 ` Cestonaro Thilo
2014-08-18 15:07 ` Greg KH
2014-08-19 12:25 ` Cestonaro Thilo
2014-08-19 12:39 ` Greg KH
2014-08-19 12:45 ` Cestonaro Thilo
2014-08-25 14:57 ` Greg KH
2014-08-18 16:19 ` Grant Edwards
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).