aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc
diff options
context:
space:
mode:
authorJohn Linn <john.linn@xilinx.com>2008-07-02 18:11:28 -0400
committerGrant Likely <grant.likely@secretlab.ca>2008-07-04 02:58:59 -0400
commitd58577d8f36f66dbb5dec30fc01dfddda0cfd1fa (patch)
tree92840d18b50ccaa63fbc4aec85c962223c5e9982 /arch/powerpc
parentdc568ec4906ac2478e2d692adc6b12fbb6e4657e (diff)
powerpc/virtex: Fix booting of Xilinx FPGAs with 16550 for 405 and 440
The following changes add processing to initialize the Xilinx 16550 UART in the boot wrapper for Virtex targets without firmware. Normally the boot wrapper assumes that the serial port has already been initialized by firmware. The wrapper was also modified to add the 440 build. Signed-off-by: John Linn <john.linn@xilinx.com> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'arch/powerpc')
-rw-r--r--arch/powerpc/boot/Makefile2
-rw-r--r--arch/powerpc/boot/simpleboot.c6
-rw-r--r--arch/powerpc/boot/virtex.c100
-rwxr-xr-xarch/powerpc/boot/wrapper6
4 files changed, 112 insertions, 2 deletions
diff --git a/arch/powerpc/boot/Makefile b/arch/powerpc/boot/Makefile
index 751a6e6070d2..df6e62116e37 100644
--- a/arch/powerpc/boot/Makefile
+++ b/arch/powerpc/boot/Makefile
@@ -68,7 +68,7 @@ src-plat := of.c cuboot-52xx.c cuboot-824x.c cuboot-83xx.c cuboot-85xx.c holly.c
68 fixed-head.S ep88xc.c ep405.c cuboot-c2k.c \ 68 fixed-head.S ep88xc.c ep405.c cuboot-c2k.c \
69 cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \ 69 cuboot-katmai.c cuboot-rainier.c redboot-8xx.c ep8248e.c \
70 cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \ 70 cuboot-warp.c cuboot-85xx-cpm2.c cuboot-yosemite.c simpleboot.c \
71 virtex405-head.S redboot-83xx.c cuboot-sam440ep.c 71 virtex405-head.S virtex.c redboot-83xx.c cuboot-sam440ep.c
72src-boot := $(src-wlib) $(src-plat) empty.c 72src-boot := $(src-wlib) $(src-plat) empty.c
73 73
74src-boot := $(addprefix $(obj)/, $(src-boot)) 74src-boot := $(addprefix $(obj)/, $(src-boot))
diff --git a/arch/powerpc/boot/simpleboot.c b/arch/powerpc/boot/simpleboot.c
index 86cd285bccc6..c58a0dada992 100644
--- a/arch/powerpc/boot/simpleboot.c
+++ b/arch/powerpc/boot/simpleboot.c
@@ -23,6 +23,8 @@
23 23
24BSS_STACK(4*1024); 24BSS_STACK(4*1024);
25 25
26extern int platform_specific_init(void) __attribute__((weak));
27
26void platform_init(unsigned long r3, unsigned long r4, unsigned long r5, 28void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
27 unsigned long r6, unsigned long r7) 29 unsigned long r6, unsigned long r7)
28{ 30{
@@ -80,5 +82,9 @@ void platform_init(unsigned long r3, unsigned long r4, unsigned long r5,
80 82
81 /* prepare the device tree and find the console */ 83 /* prepare the device tree and find the console */
82 fdt_init(_dtb_start); 84 fdt_init(_dtb_start);
85
86 if (platform_specific_init)
87 platform_specific_init();
88
83 serial_console_init(); 89 serial_console_init();
84} 90}
diff --git a/arch/powerpc/boot/virtex.c b/arch/powerpc/boot/virtex.c
new file mode 100644
index 000000000000..f622805f8000
--- /dev/null
+++ b/arch/powerpc/boot/virtex.c
@@ -0,0 +1,100 @@
1/*
2 * The platform specific code for virtex devices since a boot loader is not
3 * always used.
4 *
5 * (C) Copyright 2008 Xilinx, Inc.
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License version 2 as published
9 * by the Free Software Foundation.
10 */
11
12#include "ops.h"
13#include "io.h"
14#include "stdio.h"
15
16#define UART_DLL 0 /* Out: Divisor Latch Low */
17#define UART_DLM 1 /* Out: Divisor Latch High */
18#define UART_FCR 2 /* Out: FIFO Control Register */
19#define UART_FCR_CLEAR_RCVR 0x02 /* Clear the RCVR FIFO */
20#define UART_FCR_CLEAR_XMIT 0x04 /* Clear the XMIT FIFO */
21#define UART_LCR 3 /* Out: Line Control Register */
22#define UART_MCR 4 /* Out: Modem Control Register */
23#define UART_MCR_RTS 0x02 /* RTS complement */
24#define UART_MCR_DTR 0x01 /* DTR complement */
25#define UART_LCR_DLAB 0x80 /* Divisor latch access bit */
26#define UART_LCR_WLEN8 0x03 /* Wordlength: 8 bits */
27
28static int virtex_ns16550_console_init(void *devp)
29{
30 unsigned char *reg_base;
31 u32 reg_shift, reg_offset, clk, spd;
32 u16 divisor;
33 int n;
34
35 if (dt_get_virtual_reg(devp, (void **)&reg_base, 1) < 1)
36 return -1;
37
38 n = getprop(devp, "reg-offset", &reg_offset, sizeof(reg_offset));
39 if (n == sizeof(reg_offset))
40 reg_base += reg_offset;
41
42 n = getprop(devp, "reg-shift", &reg_shift, sizeof(reg_shift));
43 if (n != sizeof(reg_shift))
44 reg_shift = 0;
45
46 n = getprop(devp, "current-speed", (void *)&spd, sizeof(spd));
47 if (n != sizeof(spd))
48 spd = 9600;
49
50 /* should there be a default clock rate?*/
51 n = getprop(devp, "clock-frequency", (void *)&clk, sizeof(clk));
52 if (n != sizeof(clk))
53 return -1;
54
55 divisor = clk / (16 * spd);
56
57 /* Access baud rate */
58 out_8(reg_base + (UART_LCR << reg_shift), UART_LCR_DLAB);
59
60 /* Baud rate based on input clock */
61 out_8(reg_base + (UART_DLL << reg_shift), divisor & 0xFF);
62 out_8(reg_base + (UART_DLM << reg_shift), divisor >> 8);
63
64 /* 8 data, 1 stop, no parity */
65 out_8(reg_base + (UART_LCR << reg_shift), UART_LCR_WLEN8);
66
67 /* RTS/DTR */
68 out_8(reg_base + (UART_MCR << reg_shift), UART_MCR_RTS | UART_MCR_DTR);
69
70 /* Clear transmitter and receiver */
71 out_8(reg_base + (UART_FCR << reg_shift),
72 UART_FCR_CLEAR_XMIT | UART_FCR_CLEAR_RCVR);
73 return 0;
74}
75
76/* For virtex, the kernel may be loaded without using a bootloader and if so
77 some UARTs need more setup than is provided in the normal console init
78*/
79int platform_specific_init(void)
80{
81 void *devp;
82 char devtype[MAX_PROP_LEN];
83 char path[MAX_PATH_LEN];
84
85 devp = finddevice("/chosen");
86 if (devp == NULL)
87 return -1;
88
89 if (getprop(devp, "linux,stdout-path", path, MAX_PATH_LEN) > 0) {
90 devp = finddevice(path);
91 if (devp == NULL)
92 return -1;
93
94 if ((getprop(devp, "device_type", devtype, sizeof(devtype)) > 0)
95 && !strcmp(devtype, "serial")
96 && (dt_is_compatible(devp, "ns16550")))
97 virtex_ns16550_console_init(devp);
98 }
99 return 0;
100}
diff --git a/arch/powerpc/boot/wrapper b/arch/powerpc/boot/wrapper
index df2358e9f1ca..592a6ea474f6 100755
--- a/arch/powerpc/boot/wrapper
+++ b/arch/powerpc/boot/wrapper
@@ -207,7 +207,11 @@ adder875-redboot)
207 binary=y 207 binary=y
208 ;; 208 ;;
209simpleboot-virtex405-*) 209simpleboot-virtex405-*)
210 platformo="$object/virtex405-head.o $object/simpleboot.o" 210 platformo="$object/virtex405-head.o $object/simpleboot.o $object/virtex.o"
211 binary=y
212 ;;
213simpleboot-virtex440-*)
214 platformo="$object/simpleboot.o $object/virtex.o"
211 binary=y 215 binary=y
212 ;; 216 ;;
213asp834x-redboot) 217asp834x-redboot)