kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* Re: tty: uart: custom speed
       [not found] ` <20190304132302.GA9869@kroah.com>
@ 2019-03-04 14:49   ` Subhashini Rao Beerisetty
  2019-03-04 14:57     ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Subhashini Rao Beerisetty @ 2019-03-04 14:49 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-serial, kernelnewbies

On Mon, Mar 4, 2019 at 6:53 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Mon, Mar 04, 2019 at 05:46:54PM +0530, Subhashini Rao Beerisetty wrote:
> >   Hi All,
> >
> >
> > I’ve an UART ports on Xilinx FPGA board and it gets connected to PC
> > via PCIe bus. I could not find any kernel serial driver which supports
> > our hardware so I plan to develop a new driver. I see two approaches
> > to develop an UART driver i.e. either by using tty_register_driver()
> > or an uart_register_driver().
> >
> >
> > Regarding my UART module, it has a counter of 16 bits and runs on a
> > 32Mhz clock. It supports all the standard & non-standard baud’s up to
> > 4Mbps.
>
> What type of UART is it?  Odds are it is based on an existing design, no
> one creates a brand-new UART anymore.  Hopefully.  If not, what a
> waste...

For UART type, I see the permitted types are none, 8250, 16450, 16550,
16550A, 16650, 16650V2, 16654, 16750, 16850, 16950, and 16954 etc.
Looking into the data sheet I haven’t found any register or parameter
defining any of those UART types.  Is ‘UART type’ is determined from a
register settings point of view or a pinout point of view?

>
> > If I used struct tty_operations, I noticed that baud rate changing is
> > done via “.set_termios” API, but this method only supports standard
> > baud rates. I’d like to know why this API does not support
> > non-standard baud rates?
>
> Why do you think it does not?
From data sheet point of view I'm clear on how to set the non-standard
baud rate, even I exposed a custom Ioctl for this. But here I’m trying
to understand how it is achieved by using available UART kernel
framework.
For non-standard baud rate requests, observed that
tty->termios.c_ispeed & tty->termios.c_ospeed set to 38400. I did not
understood why it changes?

>
> Anyway, use the uart interface as odds are your uart is already
> supported.  Get the data sheet and start reading :)
>
> good luck,
>
> greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: tty: uart: custom speed
  2019-03-04 14:49   ` tty: uart: custom speed Subhashini Rao Beerisetty
@ 2019-03-04 14:57     ` Greg KH
  2019-03-04 15:23       ` Subhashini Rao Beerisetty
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2019-03-04 14:57 UTC (permalink / raw)
  To: Subhashini Rao Beerisetty; +Cc: linux-serial, kernelnewbies

On Mon, Mar 04, 2019 at 08:19:44PM +0530, Subhashini Rao Beerisetty wrote:
> On Mon, Mar 4, 2019 at 6:53 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> >
> > On Mon, Mar 04, 2019 at 05:46:54PM +0530, Subhashini Rao Beerisetty wrote:
> > >   Hi All,
> > >
> > >
> > > I’ve an UART ports on Xilinx FPGA board and it gets connected to PC
> > > via PCIe bus. I could not find any kernel serial driver which supports
> > > our hardware so I plan to develop a new driver. I see two approaches
> > > to develop an UART driver i.e. either by using tty_register_driver()
> > > or an uart_register_driver().
> > >
> > >
> > > Regarding my UART module, it has a counter of 16 bits and runs on a
> > > 32Mhz clock. It supports all the standard & non-standard baud’s up to
> > > 4Mbps.
> >
> > What type of UART is it?  Odds are it is based on an existing design, no
> > one creates a brand-new UART anymore.  Hopefully.  If not, what a
> > waste...
> 
> For UART type, I see the permitted types are none, 8250, 16450, 16550,
> 16550A, 16650, 16650V2, 16654, 16750, 16850, 16950, and 16954 etc.
> Looking into the data sheet I haven’t found any register or parameter
> defining any of those UART types.  Is ‘UART type’ is determined from a
> register settings point of view or a pinout point of view?

register settings point of view.

I suggest you do some basic research into how UARTs work before
continuing with this effort, it will save you a lot of time in the end
:)

> > > If I used struct tty_operations, I noticed that baud rate changing is
> > > done via “.set_termios” API, but this method only supports standard
> > > baud rates. I’d like to know why this API does not support
> > > non-standard baud rates?
> >
> > Why do you think it does not?
> From data sheet point of view I'm clear on how to set the non-standard
> baud rate, even I exposed a custom Ioctl for this. But here I’m trying
> to understand how it is achieved by using available UART kernel
> framework.
> For non-standard baud rate requests, observed that
> tty->termios.c_ispeed & tty->termios.c_ospeed set to 38400. I did not
> understood why it changes?

Have you read the documentation on how to set custom baud rates?  I
can't find the link to it at the moment, but it is very possible to do
that today, no special ioctls are needed at all.  I think someone was
finally working on getting glibc to support it directly, but I do not
know if those patches ever got merged, so you would just have to "open
code" it in userspace if you want to do this.

good luck!

greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: tty: uart: custom speed
  2019-03-04 14:57     ` Greg KH
@ 2019-03-04 15:23       ` Subhashini Rao Beerisetty
  2019-03-04 17:16         ` Vladimir Zapolskiy
  2019-03-04 18:47         ` Grant Edwards
  0 siblings, 2 replies; 6+ messages in thread
From: Subhashini Rao Beerisetty @ 2019-03-04 15:23 UTC (permalink / raw)
  To: Greg KH; +Cc: linux-serial, kernelnewbies

On Mon, Mar 4, 2019 at 8:27 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
> On Mon, Mar 04, 2019 at 08:19:44PM +0530, Subhashini Rao Beerisetty wrote:
> > On Mon, Mar 4, 2019 at 6:53 PM Greg KH <gregkh@linuxfoundation.org> wrote:
> > >
> > > On Mon, Mar 04, 2019 at 05:46:54PM +0530, Subhashini Rao Beerisetty wrote:
> > > >   Hi All,
> > > >
> > > >
> > > > I’ve an UART ports on Xilinx FPGA board and it gets connected to PC
> > > > via PCIe bus. I could not find any kernel serial driver which supports
> > > > our hardware so I plan to develop a new driver. I see two approaches
> > > > to develop an UART driver i.e. either by using tty_register_driver()
> > > > or an uart_register_driver().
> > > >
> > > >
> > > > Regarding my UART module, it has a counter of 16 bits and runs on a
> > > > 32Mhz clock. It supports all the standard & non-standard baud’s up to
> > > > 4Mbps.
> > >
> > > What type of UART is it?  Odds are it is based on an existing design, no
> > > one creates a brand-new UART anymore.  Hopefully.  If not, what a
> > > waste...
> >
> > For UART type, I see the permitted types are none, 8250, 16450, 16550,
> > 16550A, 16650, 16650V2, 16654, 16750, 16850, 16950, and 16954 etc.
> > Looking into the data sheet I haven’t found any register or parameter
> > defining any of those UART types.  Is ‘UART type’ is determined from a
> > register settings point of view or a pinout point of view?
>
> register settings point of view.
>
> I suggest you do some basic research into how UARTs work before
> continuing with this effort, it will save you a lot of time in the end
> :)

Thanks for you suggestion. I will study on this, I’m glad if you can
point some good documentation links on this.

>
> > > > If I used struct tty_operations, I noticed that baud rate changing is
> > > > done via “.set_termios” API, but this method only supports standard
> > > > baud rates. I’d like to know why this API does not support
> > > > non-standard baud rates?
> > >
> > > Why do you think it does not?
> > From data sheet point of view I'm clear on how to set the non-standard
> > baud rate, even I exposed a custom Ioctl for this. But here I’m trying
> > to understand how it is achieved by using available UART kernel
> > framework.
> > For non-standard baud rate requests, observed that
> > tty->termios.c_ispeed & tty->termios.c_ospeed set to 38400. I did not
> > understood why it changes?
>
> Have you read the documentation on how to set custom baud rates?  I
> can't find the link to it at the moment, but it is very possible to do
> that today, no special ioctls are needed at all.  I think someone was
> finally working on getting glibc to support it directly, but I do not
> know if those patches ever got merged, so you would just have to "open
> code" it in userspace if you want to do this.

I could not find clear documentation on this, I’m very much thankful
if someone point me on this. I thought of exploring TIOCGSERIAL and
TIOCSSERIAL Ioctl’s to set custom baud rates. Now it looks like I
should read the kernel code to understand how to achieve this without
special ioctls.

>
> good luck!
>
> greg k-h

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: tty: uart: custom speed
  2019-03-04 15:23       ` Subhashini Rao Beerisetty
@ 2019-03-04 17:16         ` Vladimir Zapolskiy
  2019-03-04 18:47         ` Grant Edwards
  1 sibling, 0 replies; 6+ messages in thread
From: Vladimir Zapolskiy @ 2019-03-04 17:16 UTC (permalink / raw)
  To: Subhashini Rao Beerisetty; +Cc: Greg KH, linux-serial, kernelnewbies

On 03/04/2019 05:23 PM, Subhashini Rao Beerisetty wrote:
> On Mon, Mar 4, 2019 at 8:27 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>>
>> On Mon, Mar 04, 2019 at 08:19:44PM +0530, Subhashini Rao Beerisetty wrote:
>>> On Mon, Mar 4, 2019 at 6:53 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>>>>
>>>> On Mon, Mar 04, 2019 at 05:46:54PM +0530, Subhashini Rao Beerisetty wrote:
>>>>>   Hi All,
>>>>>
>>>>>
>>>>> I’ve an UART ports on Xilinx FPGA board and it gets connected to PC
>>>>> via PCIe bus. I could not find any kernel serial driver which supports
>>>>> our hardware so I plan to develop a new driver. I see two approaches
>>>>> to develop an UART driver i.e. either by using tty_register_driver()
>>>>> or an uart_register_driver().
>>>>>
>>>>>
>>>>> Regarding my UART module, it has a counter of 16 bits and runs on a
>>>>> 32Mhz clock. It supports all the standard & non-standard baud’s up to
>>>>> 4Mbps.
>>>>
>>>> What type of UART is it?  Odds are it is based on an existing design, no
>>>> one creates a brand-new UART anymore.  Hopefully.  If not, what a
>>>> waste...
>>>
>>> For UART type, I see the permitted types are none, 8250, 16450, 16550,
>>> 16550A, 16650, 16650V2, 16654, 16750, 16850, 16950, and 16954 etc.
>>> Looking into the data sheet I haven’t found any register or parameter
>>> defining any of those UART types.  Is ‘UART type’ is determined from a
>>> register settings point of view or a pinout point of view?
>>
>> register settings point of view.
>>
>> I suggest you do some basic research into how UARTs work before
>> continuing with this effort, it will save you a lot of time in the end
>> :)
> 
> Thanks for you suggestion. I will study on this, I’m glad if you can
> point some good documentation links on this.
> 
>>
>>>>> If I used struct tty_operations, I noticed that baud rate changing is
>>>>> done via “.set_termios” API, but this method only supports standard
>>>>> baud rates. I’d like to know why this API does not support
>>>>> non-standard baud rates?
>>>>
>>>> Why do you think it does not?
>>> From data sheet point of view I'm clear on how to set the non-standard
>>> baud rate, even I exposed a custom Ioctl for this. But here I’m trying
>>> to understand how it is achieved by using available UART kernel
>>> framework.
>>> For non-standard baud rate requests, observed that
>>> tty->termios.c_ispeed & tty->termios.c_ospeed set to 38400. I did not
>>> understood why it changes?
>>
>> Have you read the documentation on how to set custom baud rates?  I
>> can't find the link to it at the moment, but it is very possible to do
>> that today, no special ioctls are needed at all.  I think someone was
>> finally working on getting glibc to support it directly, but I do not
>> know if those patches ever got merged, so you would just have to "open
>> code" it in userspace if you want to do this.
> 
> I could not find clear documentation on this, I’m very much thankful
> if someone point me on this. I thought of exploring TIOCGSERIAL and
> TIOCSSERIAL Ioctl’s to set custom baud rates. Now it looks like I
> should read the kernel code to understand how to achieve this without
> special ioctls.
> 

You should try to set a custom baudrate with help of TCSETS2:

----8<----

static int set_speed(int fd, speed_t speed)
{
	struct termios2 tio;
	int ret;

	ret = ioctl(fd, TCGETS2, &tio);
	if (ret) {
		printf("TCGETS2 failed: %d\n", ret);
		return ret;
	}

	tio.c_cflag &= ~CBAUD;
	tio.c_cflag |= BOTHER;
	tio.c_ispeed = speed;
	tio.c_ospeed = speed;

	ret = ioctl(fd, TCSETS2, &tio);
	if (ret) {
		printf("TCSETS2 failed to set speed %u: %d\n", speed, ret);
		return ret;
	}

	return 0;
}

----8<----

--
Best wishes,
Vladimir

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: tty: uart: custom speed
  2019-03-04 15:23       ` Subhashini Rao Beerisetty
  2019-03-04 17:16         ` Vladimir Zapolskiy
@ 2019-03-04 18:47         ` Grant Edwards
  1 sibling, 0 replies; 6+ messages in thread
From: Grant Edwards @ 2019-03-04 18:47 UTC (permalink / raw)
  To: kernelnewbies; +Cc: linux-serial

On 2019-03-04, Subhashini Rao Beerisetty <subhashbeerisetty@gmail.com> wrote:
> On Mon, Mar 4, 2019 at 8:27 PM Greg KH <gregkh@linuxfoundation.org> wrote:
>
>> Have you read the documentation on how to set custom baud rates?  I
>> can't find the link to it at the moment, but it is very possible to do
>> that today, no special ioctls are needed at all.  I think someone was
>> finally working on getting glibc to support it directly, but I do not
>> know if those patches ever got merged, so you would just have to "open
>> code" it in userspace if you want to do this.
>
> I could not find clear documentation on this, I’m very much thankful
> if someone point me on this. I thought of exploring TIOCGSERIAL and
> TIOCSSERIAL Ioctl’s to set custom baud rates. Now it looks like I
> should read the kernel code to understand how to achieve this without
> special ioctls.

You use the termios2 structure and TCGETS2/TCSETS ioctl calls:

    http://www.panix.com/~grante/arbitrary-baud.c

-- 
Grant








_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 6+ messages in thread

* tty: uart: custom speed
@ 2019-03-04 12:12 Subhashini Rao Beerisetty
  0 siblings, 0 replies; 6+ messages in thread
From: Subhashini Rao Beerisetty @ 2019-03-04 12:12 UTC (permalink / raw)
  To: kernelnewbies; +Cc: linux-tty

 Hi All,


I’ve an UART ports on Xilinx FPGA board and it gets connected to PC
via PCIe bus. I could not find any kernel serial driver which supports
our hardware so I plan to develop a new driver. I see two approaches
to develop an UART driver i.e. either by using tty_register_driver()
or an uart_register_driver().


Regarding my UART module, it has a counter of 16 bits and runs on a
32Mhz clock. It supports all the standard & non-standard baud’s up to
4Mbps.


If I used struct tty_operations, I noticed that baud rate changing is
done via “.set_termios” API, but this method only supports standard
baud rates. I’d like to know why this API does not support
non-standard baud rates?


Okay, what methods a good driver should implement to support
non-standard baud rates?

Thanks

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@kernelnewbies.org
https://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-03-04 22:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAPY=qRSrw7JxAbORoUHckxcMRjk16zYP7nc2zakGd411JMjGjA@mail.gmail.com>
     [not found] ` <20190304132302.GA9869@kroah.com>
2019-03-04 14:49   ` tty: uart: custom speed Subhashini Rao Beerisetty
2019-03-04 14:57     ` Greg KH
2019-03-04 15:23       ` Subhashini Rao Beerisetty
2019-03-04 17:16         ` Vladimir Zapolskiy
2019-03-04 18:47         ` Grant Edwards
2019-03-04 12:12 Subhashini Rao Beerisetty

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).