Re: [PATCH] Xilinx UART Lite 2.6.18 driver
From: Peter Korsgaard <jacmet@sunsite.dk>
Date: 2006-11-06 15:44:20
quoted
quoted
quoted
quoted
"David" == David Bolcsfoldi [off-list ref] writes:
Hi,
quoted
This doesn't help much as you don't use the com_port argument in the other functions.
David> True, it's utterly useless. I was planning on having an array David> with base addresses which would be used to support the com_port David> argument. But it didn't make it in this patch although I have David> version that does this now. You don't even need an array - you can use use the base address as the com_port cookie, E.G.:
--- /dev/null
+++ linux-trunk/arch/ppc/boot/simple/uartlite_tty.c@@ -0,0 +1,86 @@ +/* + * Boot support for Xilinx uartlite + * + * Copyright (C) 2006 David Bolcsfoldi <dbolcsfoldi@gmail.com> + * + * This file is licensed under the terms of the GNU General Public License + * version 2. This program is licensed "as is" without any warranty of any + * kind, whether express or implied. + */ + +#include <asm/io.h> +#include <linux/serial_uartlite.h> +#include <platforms/4xx/xparameters/xparameters.h> + +unsigned long serial_init(int chan, void *ignored) +{ + unsigned long com_port = 0; + + switch (chan) { +#ifdef XPAR_UARTLITE_0_BASEADDR + case 0: + com_port = XPAR_UARTLITE_0_BASEADDR + 3; + break; +#endif +#ifdef XPAR_UARTLITE_1_BASEADDR + case 1: + com_port = XPAR_UARTLITE_1_BASEADDR + 3; + break; +#endif +#ifdef XPAR_UARTLITE_2_BASEADDR + case 2: + com_port = XPAR_UARTLITE_2_BASEADDR + 3; + break; +#endif +#ifdef XPAR_UARTLITE_3_BASEADDR + case 3: + com_port = XPAR_UARTLITE_3_BASEADDR + 3; + break; +#endif + default: + break; + } + + if (com_port) { + void __iomem *base = (void __iomem*)com_port; + writeb(0, base + ULITE_CONTROL); + writeb(ULITE_CONTROL_RST_RX | ULITE_CONTROL_RST_TX, + base + ULITE_CONTROL); + writeb(0, base + ULITE_CONTROL); + } + + return com_port; +} + + +int serial_tstc(unsigned long com_port) +{ + void __iomem *base = (void __iomem*)com_port; + + if (base) + return readb(base + ULITE_STATUS) & ULITE_STATUS_RXVALID; + else + return 0; +} + +void serial_putc(unsigned long com_port, unsigned char c) +{ + void __iomem *base = (void __iomem*)com_port; + + if (base) { + while (readb(base + ULITE_STATUS) & ULITE_STATUS_TXFULL); + writeb(c, base + ULITE_TX); + } +} + +unsigned char serial_getc(unsigned long com_port) +{ + void __iomem *base = (void __iomem*)com_port; + + if (base) { + while (!serial_tstc(com_port)); + return readb(base + ULITE_RX); + } + else + return 0; +}
quoted
Where did you get the XPAR_XUL_UART_ defines from? Our xparameters.h seem to contain XPAR_UARTLITE_ defines instead.
David> I think that name is picked up from the name of the device in your David> design, the defines get names XPAR_NNN_ and mine are called David> XUL_UART. Crap - Ok, then people just have to add linux-compatible defines to the end of their xparameters.h - E.G #define XPAR_UARTLITE_0_BASEADDR XPAR_XUL_UART_BASEADDR
quoted
You can always use the ppc_md.progress() stuff for really early debugging if needed. I would prefer to keep this workaround out of uartlite.c if it isn't needed.
David> I am pretty certain probe won't get called until ppc_sys_init has been David> called which is fairly far into the booting process and even if David> it did the platform_bus hasn't been initialized before the David> ppc_sys_init is called, at least not with any of the devices David> exported by ppc_sys_devices. True. For really early stuff you'll need to use ppc_md.progress() (or some additional hacking) David> Thanks for the review! David You're welcome. -- Bye, Peter Korsgaard