-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[POWERPC] Virtex: Add uartlite bootwrapper driver
Allows the bootwrapper to use the uartlite device for console output. Signed-off-by: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
- Loading branch information
Grant Likely
authored and
Josh Boyer
committed
Oct 3, 2007
1 parent
340ffd2
commit 7ddc5f9
Showing
4 changed files
with
68 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
/* | ||
* Xilinx UARTLITE bootloader driver | ||
* | ||
* Copyright (C) 2007 Secret Lab Technologies Ltd. | ||
* | ||
* 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 <stdarg.h> | ||
#include <stddef.h> | ||
#include "types.h" | ||
#include "string.h" | ||
#include "stdio.h" | ||
#include "io.h" | ||
#include "ops.h" | ||
|
||
static void * reg_base; | ||
|
||
static int uartlite_open(void) | ||
{ | ||
/* Clear the RX FIFO */ | ||
out_be32(reg_base + 0x0C, 0x2); | ||
return 0; | ||
} | ||
|
||
static void uartlite_putc(unsigned char c) | ||
{ | ||
while ((in_be32(reg_base + 0x8) & 0x08) != 0); /* spin */ | ||
out_be32(reg_base + 0x4, c); | ||
} | ||
|
||
static unsigned char uartlite_getc(void) | ||
{ | ||
while ((in_be32(reg_base + 0x8) & 0x01) == 0); /* spin */ | ||
return in_be32(reg_base); | ||
} | ||
|
||
static u8 uartlite_tstc(void) | ||
{ | ||
return ((in_be32(reg_base + 0x8) & 0x01) != 0); | ||
} | ||
|
||
int uartlite_console_init(void *devp, struct serial_console_data *scdp) | ||
{ | ||
int n; | ||
unsigned long reg_phys; | ||
|
||
n = getprop(devp, "virtual-reg", ®_base, sizeof(reg_base)); | ||
if (n != sizeof(reg_base)) { | ||
if (!dt_xlate_reg(devp, 0, ®_phys, NULL)) | ||
return -1; | ||
|
||
reg_base = (void *)reg_phys; | ||
} | ||
|
||
scdp->open = uartlite_open; | ||
scdp->putc = uartlite_putc; | ||
scdp->getc = uartlite_getc; | ||
scdp->tstc = uartlite_tstc; | ||
scdp->close = NULL; | ||
return 0; | ||
} |