From: "Johann Baudy" <johaahn@gmail.com>
To: "John Linn" <john.linn@xilinx.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: [PATCH 3/3][POWERPC][V2] Xilinx: boot support for Xilinx uart 16550.
Date: Thu, 3 Apr 2008 13:23:10 +0000 [thread overview]
Message-ID: <7e0dd21a0804030623s3571716fk8585b517c9aac1ed@mail.gmail.com> (raw)
In-Reply-To: <20080402165216.C835D1CF8088@mail12-sin.bigfish.com>
[-- Attachment #1: Type: text/plain, Size: 3611 bytes --]
Hi John,
I've a small question about ns16550 boot support.
I can't see any code related to either "clock-frequency" or "current-speed"
key words.
Such actions are performed in of_serial.c to get appropriate baud rate
(update of UART_DLL and UART_DLM).
Is it needed or is it a misunderstanding?
Personally, I have added this below debug code (dirty :)) to make it work.
diff --git a/arch/powerpc/boot/ns16550.c b/arch/powerpc/boot/ns16550.c
index f8f1b2f..850e223 100644
--- a/arch/powerpc/boot/ns16550.c
+++ b/arch/powerpc/boot/ns16550.c
@@ -26,6 +26,9 @@
#define UART_MSR 6 /* In: Modem Status Register */
#define UART_SCR 7 /* I/O: Scratch Register */
+#define UART_LCR_DLAB 0x80 /* Divisor latch access */
+#define UART_LCR_8_DATA_BITS 0x03
+
static unsigned char *reg_base;
static u32 reg_shift;
@@ -56,6 +59,10 @@ int ns16550_console_init(void *devp, struct
serial_console_data *scdp)
{
int n;
unsigned long reg_phys;
+ unsigned long divisor=0;
+ unsigned long spd=0, clk=0;
+
+
n = getprop(devp, "virtual-reg", ®_base, sizeof(reg_base));
if (n != sizeof(reg_base)) {
@@ -75,5 +82,23 @@ int ns16550_console_init(void *devp, struct
serial_console_data *scdp)
scdp->tstc = ns16550_tstc;
scdp->close = NULL;
+ n = getprop(devp, "current-speed", &spd, sizeof(spd));
+
+
+ n = getprop(devp, "clock-frequency", &clk, sizeof(clk));
+
+
+ if(spd&&clk)
+ {
+
+ divisor = clk / (spd * 16UL);
+
+ out_8(reg_base + (UART_FCR << reg_shift), 0x06);
+ out_8(reg_base + (UART_LCR << reg_shift),
UART_LCR_8_DATA_BITS|UART_LCR_DLAB);
+ out_8(reg_base + (UART_DLL << reg_shift), divisor&0xff);
+ out_8(reg_base + (UART_DLM << reg_shift), (divisor>>8)&0xff);
+ out_8(reg_base + (UART_LCR << reg_shift), UART_LCR_8_DATA_BITS);
+
+ }
return 0;
Best regards,
Johann
On Wed, Apr 2, 2008 at 4:52 PM, John Linn <john.linn@xilinx.com> wrote:
> The Xilinx 16550 uart core is not a standard 16550 because it uses
> word-based addressing rather than byte-based adressing. With
> additional properties it is compatible with the open firmware
> 'ns16550' compatible binding.
>
> This code updates the ns16550 driver to use the reg-offset property
> so that the Xilinx UART 16550 can be used with it. The reg-shift
> was already being handled.
>
> Signed-off-by: John Linn <john.linn@xilinx.com>
> ---
> arch/powerpc/boot/ns16550.c | 5 +++++
> 1 files changed, 5 insertions(+), 0 deletions(-)
>
> diff --git a/arch/powerpc/boot/ns16550.c b/arch/powerpc/boot/ns16550.c
> index f8f1b2f..da9d2c2 100644
> --- a/arch/powerpc/boot/ns16550.c
> +++ b/arch/powerpc/boot/ns16550.c
> @@ -56,6 +56,7 @@ int ns16550_console_init(void *devp, struct
> serial_console_data *scdp)
> {
> int n;
> unsigned long reg_phys;
> + u32 reg_offset;
>
> n = getprop(devp, "virtual-reg", ®_base, sizeof(reg_base));
> if (n != sizeof(reg_base)) {
> @@ -65,6 +66,10 @@ int ns16550_console_init(void *devp, struct
> serial_console_data *scdp)
> reg_base = (void *)reg_phys;
> }
>
> + n = getprop(devp, "reg-offset", ®_offset, sizeof(reg_offset));
> + if (n == sizeof(reg_offset))
> + reg_base += reg_offset;
> +
> n = getprop(devp, "reg-shift", ®_shift, sizeof(reg_shift));
> if (n != sizeof(reg_shift))
> reg_shift = 0;
> --
> 1.5.2.1
>
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@ozlabs.org
> https://ozlabs.org/mailman/listinfo/linuxppc-dev
>
--
Johann Baudy
johaahn@gmail.com
[-- Attachment #2: Type: text/html, Size: 5376 bytes --]
next prev parent reply other threads:[~2008-04-03 13:23 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <12071551351007-git-send-email-john.linn@xilinx.com>
2008-04-02 16:52 ` [PATCH 3/3][POWERPC][V2] Xilinx: boot support for Xilinx uart 16550 John Linn
2008-04-02 17:52 ` Grant Likely
2008-04-03 0:02 ` David Gibson
2008-04-03 1:16 ` Grant Likely
2008-04-03 13:23 ` Johann Baudy [this message]
2008-04-03 13:28 ` John Linn
2008-04-03 14:05 ` Grant Likely
[not found] ` <12071551354058-git-send-email-john.linn@xilinx.com>
2008-04-02 16:52 ` [PATCH 2/3][POWERPC][V2] Xilinx: of_serial " John Linn
2008-04-02 18:00 ` Grant Likely
2008-04-02 18:20 ` John Linn
2008-04-02 19:27 ` Grant Likely
2008-04-02 19:19 ` Sergei Shtylyov
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=7e0dd21a0804030623s3571716fk8585b517c9aac1ed@mail.gmail.com \
--to=johaahn@gmail.com \
--cc=john.linn@xilinx.com \
--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 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).