From: Wolfram Sang <w.sang@pengutronix.de>
To: "Albrecht Dre�" <albrecht.dress@arcor.de>
Cc: linuxppc-dev@ozlabs.org, devicetree-discuss@lists.ozlabs.org
Subject: Re: [Patch] mpc5200b: improve baud rate calculation (reach high baud rates, better accuracy)
Date: Tue, 2 Mar 2010 09:28:58 +0100 [thread overview]
Message-ID: <20100302082858.GA4087@pengutronix.de> (raw)
In-Reply-To: <14429243.1267517383754.JavaMail.ngmail@webmail14.arcor-online.net>
[-- Attachment #1: Type: text/plain, Size: 2355 bytes --]
> [snip]
> > > + if (is_mpc5200b == 1)
> > > + return mpc5xxx_get_bus_frequency(p) * 4;
> > > + else
> > > + return mpc5xxx_get_bus_frequency(p) / 2;
> >
> > Isn't this wrong? You can also have /32 on the 5200B (the fallback).
>
> Yes, but I do all /calculations/ with the /4 prescaler for higher accuracy.
> If the divisor exceeds the available 16 bits of the counter reg, I round
> (divisor / 8) to use the /32 prescaler. Think of a 19-bit counter value,
> where I can choose to use either the lower or the higher 16 bits for the
> counter reg.
Okay, now I got it. (Maybe this is an indication for another comment above the
set divisor function?)
> Remember also that using the higher 16 bits (/32 prescaler) is
> probably the exceptional case - with an IPB frequency of 132 MHz this will
> happen only for standard baud rates B300 and slower.
Even the rare cases have to be correct ;)
> [snip]
> > > + /* Check only once if we are running on a mpc5200b or not */
> > > + if (is_mpc5200b == -1) {
> > > + struct device_node *np;
> > > +
> > > + np = of_find_compatible_node(NULL, NULL, "fsl,mpc5200b-immr");
> >
> > This should be handled using a new compatible-entry
> > "fsl,mpc5200b-psc-uart".
>
> I agree that this would be a lot cleaner, but it's also a lot more intrusive.
> CC'ing the device tree discussion list here... comments, please!!
Why intrusive? Maybe I miss something?
> > You could also have a set_divisor-function for 5200 and 5200B and set it
> > here in the function struct (one reason less for the static ;))
>
> Hmmm, but then I would need a 'static struct psc_ops mpc5200b_psc_ops', where
> only two functions differ from the generic 52xx struct as it is implemented
> now. Using the static int needs less space. However, in combination with
> the new compatible entry, it would of course make sense.
Leave those two function pointers empty and fill them during probe (probe has
access to the compatible-property it was matched against, see its arguments).
So it should be a matter of:
if (matched_property == 5200b)
ops->func = this_one;
else
ops->func = that_one;
Regards,
Wolfram
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
WARNING: multiple messages have this Message-ID (diff)
From: Wolfram Sang <w.sang@pengutronix.de>
To: "Albrecht Dre�" <albrecht.dress@arcor.de>
Cc: linuxppc-dev@ozlabs.org, devicetree-discuss@lists.ozlabs.org
Subject: Re: [Patch] mpc5200b: improve baud rate calculation (reach high baud rates, better accuracy)
Date: Tue, 2 Mar 2010 09:28:58 +0100 [thread overview]
Message-ID: <20100302082858.GA4087@pengutronix.de> (raw)
In-Reply-To: <14429243.1267517383754.JavaMail.ngmail@webmail14.arcor-online.net>
[-- Attachment #1.1: Type: text/plain, Size: 2355 bytes --]
> [snip]
> > > + if (is_mpc5200b == 1)
> > > + return mpc5xxx_get_bus_frequency(p) * 4;
> > > + else
> > > + return mpc5xxx_get_bus_frequency(p) / 2;
> >
> > Isn't this wrong? You can also have /32 on the 5200B (the fallback).
>
> Yes, but I do all /calculations/ with the /4 prescaler for higher accuracy.
> If the divisor exceeds the available 16 bits of the counter reg, I round
> (divisor / 8) to use the /32 prescaler. Think of a 19-bit counter value,
> where I can choose to use either the lower or the higher 16 bits for the
> counter reg.
Okay, now I got it. (Maybe this is an indication for another comment above the
set divisor function?)
> Remember also that using the higher 16 bits (/32 prescaler) is
> probably the exceptional case - with an IPB frequency of 132 MHz this will
> happen only for standard baud rates B300 and slower.
Even the rare cases have to be correct ;)
> [snip]
> > > + /* Check only once if we are running on a mpc5200b or not */
> > > + if (is_mpc5200b == -1) {
> > > + struct device_node *np;
> > > +
> > > + np = of_find_compatible_node(NULL, NULL, "fsl,mpc5200b-immr");
> >
> > This should be handled using a new compatible-entry
> > "fsl,mpc5200b-psc-uart".
>
> I agree that this would be a lot cleaner, but it's also a lot more intrusive.
> CC'ing the device tree discussion list here... comments, please!!
Why intrusive? Maybe I miss something?
> > You could also have a set_divisor-function for 5200 and 5200B and set it
> > here in the function struct (one reason less for the static ;))
>
> Hmmm, but then I would need a 'static struct psc_ops mpc5200b_psc_ops', where
> only two functions differ from the generic 52xx struct as it is implemented
> now. Using the static int needs less space. However, in combination with
> the new compatible entry, it would of course make sense.
Leave those two function pointers empty and fill them during probe (probe has
access to the compatible-property it was matched against, see its arguments).
So it should be a matter of:
if (matched_property == 5200b)
ops->func = this_one;
else
ops->func = that_one;
Regards,
Wolfram
--
Pengutronix e.K. | Wolfram Sang |
Industrial Linux Solutions | http://www.pengutronix.de/ |
[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
[-- Attachment #2: Type: text/plain, Size: 150 bytes --]
_______________________________________________
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev
next prev parent reply other threads:[~2010-03-02 8:29 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-03-02 8:09 [Patch] mpc5200b: improve baud rate calculation (reach high baud rates, better accuracy) Albrecht Dreß
2010-03-02 8:09 ` Albrecht Dreß
2010-03-02 8:28 ` Wolfram Sang [this message]
2010-03-02 8:28 ` Wolfram Sang
2010-03-02 8:56 ` Albrecht Dreß
2010-03-02 8:56 ` Albrecht Dreß
2010-03-02 15:27 ` Wolfram Sang
2010-03-02 15:27 ` Wolfram Sang
2010-03-02 20:12 ` Grant Likely
2010-03-02 20:12 ` Grant Likely
2010-03-02 20:06 ` Grant Likely
2010-03-02 20:06 ` Grant Likely
-- strict thread matches above, loose matches on Subject: below --
2010-03-01 18:11 Albrecht Dreß
2010-03-02 0:32 ` Wolfram Sang
2010-03-02 20:22 ` Grant Likely
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=20100302082858.GA4087@pengutronix.de \
--to=w.sang@pengutronix.de \
--cc=albrecht.dress@arcor.de \
--cc=devicetree-discuss@lists.ozlabs.org \
--cc=linuxppc-dev@ozlabs.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.