From: Jan Kiszka <jan.kiszka@domain.hid>
To: CHABAL David <david.chabal@domain.hid>
Cc: xenomai@xenomai.org
Subject: Re: [Xenomai-core] 16550A driver and Moxa card / solved
Date: Fri, 11 May 2007 11:08:07 +0200 [thread overview]
Message-ID: <46443277.3060102@domain.hid> (raw)
In-Reply-To: <XqI9Fhxa.1178875870.3777430.dchabal@domain.hid>
[-- Attachment #1: Type: text/plain, Size: 2713 bytes --]
CHABAL David wrote:
> Hello,
>
> I met some trouble with the 16550A driver provided in Xenomai 2.3.1
> and my Moxa cards (PCI / 8 * RS232 / 168U ).
>
> It was a problem of baudrate computation before setting the LCR_DLAB
> register.
>
> The formula implemented by the Xenomai driver is different from the one
> provided by Moxa. So I copy/paste the formula from the mxser.c file
> (present in the
> kernel distro), and it seems to work fine.
>
> I think it's Moxa card dependant, may be caused by the high default baud
> rate of this card.
>
> I post here my patch below, it may interest someone.
Thanks for sharing your findings. Will check if/how we can integrate
them. See some comments below already.
[Reminds me that there are more 16550A patches pending in my inbox... :-/]
>
> David
>
> ----------------------------------------------
>
>
>
> @@ -29,7 +29,7 @@
> #define IN_BUFFER_SIZE 4096
> #define OUT_BUFFER_SIZE 4096
>
> -#define DEFAULT_BAUD_BASE 115200
> +#define DEFAULT_BAUD_BASE 921600
OK, that's for your convenience right now. We also have a module
parameter to set the base.
> #define DEFAULT_TX_FIFO 16
>
> #define PARITY_MASK 0x03
> @@ -316,8 +316,23 @@
>
> if (testbits(config->config_mask, RTSER_SET_BAUD)) {
> ctx->config.baud_rate = config->baud_rate;
> - baud_div = (baud_base[dev_id] + (ctx->config.baud_rate >> 1)) /
> - ctx->config.baud_rate;
> + if (ctx->config.baud_rate == 134)
> + {
> + baud_div = (2 * baud_base[dev_id] / 269);
> + }
Well, whoever needs such low rates in practice these days... :)
> + else
> + {
> + if (ctx->config.baud_rate)
Oops, that check protects us from dividing by zero - should be fixed in
any case! Or is baud_div = 0 a special mode with Moxa?
> + {
> + baud_div = baud_base[dev_id] / ctx->config.baud_rate;
So this means dividing with round down instead of round up. We could
enable this mode with an additional module parameter, something like
variant = {0: standard, 1: moxa, ...}. That could also raise the default
baudbase for the particular port.
> + if (baud_div == 0)
> + baud_div = 1;
That shouldn't trigger with xeno_16550A because we catch baud_rate >
baud_base already in rt_16550_ioctl.
> + }
> + else
> + {
> + baud_div = 0;
> + }
> + }
> outb(LCR_DLAB, LCR(dev_id));
> outb(baud_div & 0xff, DLL(dev_id));
> outb(baud_div >> 8, DLM(dev_id));
>
Jan
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 250 bytes --]
next prev parent reply other threads:[~2007-05-11 9:08 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-11 9:31 [Xenomai-core] 16550A driver and Moxa card / solved CHABAL David
2007-05-11 9:08 ` Jan Kiszka [this message]
2007-05-11 9:12 ` Maksym Veremeyenko
2007-05-11 9:17 ` Jan Kiszka
2007-05-11 10:57 ` CHABAL David
2007-05-11 10:28 ` Maksym Veremeyenko
2007-05-11 10:36 ` Jan Kiszka
2007-05-11 11:25 ` Jan Kiszka
2007-05-11 12:33 ` CHABAL David
2007-05-11 11:46 ` Maksym Veremeyenko
2007-05-11 12:11 ` Jan Kiszka
2007-05-11 14:11 ` CHABAL David
2007-05-11 13:25 ` Jan Kiszka
2007-05-11 13:35 ` Maksym Veremeyenko
2007-05-11 14:33 ` CHABAL David
2007-05-11 13:54 ` Jan Kiszka
2007-05-11 13:58 ` Maksym Veremeyenko
2007-05-11 15:33 ` CHABAL David
2007-05-11 15:45 ` Jan Kiszka
2007-05-11 13:29 ` Maksym Veremeyenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46443277.3060102@domain.hid \
--to=jan.kiszka@domain.hid \
--cc=david.chabal@domain.hid \
--cc=xenomai@xenomai.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.