aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/Makefile7
-rw-r--r--arch/powerpc/kernel/btext.c130
-rw-r--r--arch/powerpc/kernel/head_32.S29
-rw-r--r--arch/powerpc/kernel/setup_32.c28
-rw-r--r--arch/powerpc/kernel/setup_64.c4
-rw-r--r--arch/powerpc/kernel/udbg.c8
-rw-r--r--arch/powerpc/kernel/udbg_16550.c4
-rw-r--r--arch/powerpc/kernel/udbg_scc.c135
8 files changed, 147 insertions, 198 deletions
diff --git a/arch/powerpc/kernel/Makefile b/arch/powerpc/kernel/Makefile
index bf3fd6f02249..89714929f444 100644
--- a/arch/powerpc/kernel/Makefile
+++ b/arch/powerpc/kernel/Makefile
@@ -18,7 +18,7 @@ obj-y += vdso32/
18obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \ 18obj-$(CONFIG_PPC64) += setup_64.o binfmt_elf32.o sys_ppc32.o \
19 signal_64.o ptrace32.o systbl.o \ 19 signal_64.o ptrace32.o systbl.o \
20 paca.o ioctl32.o cpu_setup_power4.o \ 20 paca.o ioctl32.o cpu_setup_power4.o \
21 firmware.o sysfs.o udbg.o idle_64.o 21 firmware.o sysfs.o idle_64.o
22obj-$(CONFIG_PPC64) += vdso64/ 22obj-$(CONFIG_PPC64) += vdso64/
23obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o 23obj-$(CONFIG_ALTIVEC) += vecemu.o vector.o
24obj-$(CONFIG_POWER4) += idle_power4.o 24obj-$(CONFIG_POWER4) += idle_power4.o
@@ -46,7 +46,7 @@ extra-$(CONFIG_8xx) := head_8xx.o
46extra-y += vmlinux.lds 46extra-y += vmlinux.lds
47 47
48obj-y += process.o init_task.o time.o \ 48obj-y += process.o init_task.o time.o \
49 prom.o traps.o setup-common.o 49 prom.o traps.o setup-common.o udbg.o
50obj-$(CONFIG_PPC32) += entry_32.o setup_32.o misc_32.o systbl.o 50obj-$(CONFIG_PPC32) += entry_32.o setup_32.o misc_32.o systbl.o
51obj-$(CONFIG_PPC64) += misc_64.o dma_64.o iommu.o 51obj-$(CONFIG_PPC64) += misc_64.o dma_64.o iommu.o
52obj-$(CONFIG_PPC_OF) += prom_init.o 52obj-$(CONFIG_PPC_OF) += prom_init.o
@@ -56,8 +56,7 @@ obj-$(CONFIG_6xx) += idle_6xx.o
56obj-$(CONFIG_SMP) += smp.o 56obj-$(CONFIG_SMP) += smp.o
57obj-$(CONFIG_KPROBES) += kprobes.o 57obj-$(CONFIG_KPROBES) += kprobes.o
58obj-$(CONFIG_PPC_MULTIPLATFORM) += legacy_serial.o 58obj-$(CONFIG_PPC_MULTIPLATFORM) += legacy_serial.o
59obj64-$(CONFIG_PPC_MULTIPLATFORM) += udbg_16550.o 59obj-$(CONFIG_PPC_MULTIPLATFORM) += udbg_16550.o
60obj64-$(CONFIG_PPC_PMAC) += udbg_scc.o
61module-$(CONFIG_PPC64) += module_64.o 60module-$(CONFIG_PPC64) += module_64.o
62obj-$(CONFIG_MODULES) += $(module-y) 61obj-$(CONFIG_MODULES) += $(module-y)
63 62
diff --git a/arch/powerpc/kernel/btext.c b/arch/powerpc/kernel/btext.c
index bdfba92b2b38..893dd24a9f67 100644
--- a/arch/powerpc/kernel/btext.c
+++ b/arch/powerpc/kernel/btext.c
@@ -31,15 +31,18 @@ static void draw_byte_32(unsigned char *bits, unsigned int *base, int rb);
31static void draw_byte_16(unsigned char *bits, unsigned int *base, int rb); 31static void draw_byte_16(unsigned char *bits, unsigned int *base, int rb);
32static void draw_byte_8(unsigned char *bits, unsigned int *base, int rb); 32static void draw_byte_8(unsigned char *bits, unsigned int *base, int rb);
33 33
34static int g_loc_X; 34#define __force_data __attribute__((__section__(".data")))
35static int g_loc_Y;
36static int g_max_loc_X;
37static int g_max_loc_Y;
38 35
39static int dispDeviceRowBytes; 36static int g_loc_X __force_data;
40static int dispDeviceDepth; 37static int g_loc_Y __force_data;
41static int dispDeviceRect[4]; 38static int g_max_loc_X __force_data;
42static unsigned char *dispDeviceBase, *logicalDisplayBase; 39static int g_max_loc_Y __force_data;
40
41static int dispDeviceRowBytes __force_data;
42static int dispDeviceDepth __force_data;
43static int dispDeviceRect[4] __force_data;
44static unsigned char *dispDeviceBase __force_data;
45static unsigned char *logicalDisplayBase __force_data;
43 46
44unsigned long disp_BAT[2] __initdata = {0, 0}; 47unsigned long disp_BAT[2] __initdata = {0, 0};
45 48
@@ -47,7 +50,7 @@ unsigned long disp_BAT[2] __initdata = {0, 0};
47 50
48static unsigned char vga_font[cmapsz]; 51static unsigned char vga_font[cmapsz];
49 52
50int boot_text_mapped; 53int boot_text_mapped __force_data = 0;
51int force_printk_to_btext = 0; 54int force_printk_to_btext = 0;
52 55
53#ifdef CONFIG_PPC32 56#ifdef CONFIG_PPC32
@@ -66,8 +69,7 @@ int force_printk_to_btext = 0;
66 * is really badly aligned, but I didn't encounter this case 69 * is really badly aligned, but I didn't encounter this case
67 * yet. 70 * yet.
68 */ 71 */
69void __init 72void __init btext_prepare_BAT(void)
70btext_prepare_BAT(void)
71{ 73{
72 unsigned long vaddr = KERNELBASE + 0x10000000; 74 unsigned long vaddr = KERNELBASE + 0x10000000;
73 unsigned long addr; 75 unsigned long addr;
@@ -95,12 +97,13 @@ btext_prepare_BAT(void)
95} 97}
96#endif 98#endif
97 99
98/* This function will enable the early boot text when doing OF booting. This 100
99 * way, xmon output should work too 101/* This function can be used to enable the early boot text when doing
102 * OF booting or within bootx init. It must be followed by a btext_unmap()
103 * call before the logical address becomes unuseable
100 */ 104 */
101void __init 105void __init btext_setup_display(int width, int height, int depth, int pitch,
102btext_setup_display(int width, int height, int depth, int pitch, 106 unsigned long address)
103 unsigned long address)
104{ 107{
105 g_loc_X = 0; 108 g_loc_X = 0;
106 g_loc_Y = 0; 109 g_loc_Y = 0;
@@ -116,6 +119,11 @@ btext_setup_display(int width, int height, int depth, int pitch,
116 boot_text_mapped = 1; 119 boot_text_mapped = 1;
117} 120}
118 121
122void __init btext_unmap(void)
123{
124 boot_text_mapped = 0;
125}
126
119/* Here's a small text engine to use during early boot 127/* Here's a small text engine to use during early boot
120 * or for debugging purposes 128 * or for debugging purposes
121 * 129 *
@@ -127,7 +135,7 @@ btext_setup_display(int width, int height, int depth, int pitch,
127 * changes. 135 * changes.
128 */ 136 */
129 137
130void map_boot_text(void) 138static void map_boot_text(void)
131{ 139{
132 unsigned long base, offset, size; 140 unsigned long base, offset, size;
133 unsigned char *vbase; 141 unsigned char *vbase;
@@ -175,8 +183,9 @@ int btext_initialize(struct device_node *np)
175 if (prop) 183 if (prop)
176 address = *prop; 184 address = *prop;
177 185
178 /* FIXME: Add support for PCI reg properties */ 186 /* FIXME: Add support for PCI reg properties. Right now, only
179 187 * reliable on macs
188 */
180 if (address == 0) 189 if (address == 0)
181 return -EINVAL; 190 return -EINVAL;
182 191
@@ -184,7 +193,6 @@ int btext_initialize(struct device_node *np)
184 g_loc_Y = 0; 193 g_loc_Y = 0;
185 g_max_loc_X = width / 8; 194 g_max_loc_X = width / 8;
186 g_max_loc_Y = height / 16; 195 g_max_loc_Y = height / 16;
187 logicalDisplayBase = (unsigned char *)address;
188 dispDeviceBase = (unsigned char *)address; 196 dispDeviceBase = (unsigned char *)address;
189 dispDeviceRowBytes = pitch; 197 dispDeviceRowBytes = pitch;
190 dispDeviceDepth = depth; 198 dispDeviceDepth = depth;
@@ -197,7 +205,7 @@ int btext_initialize(struct device_node *np)
197 return 0; 205 return 0;
198} 206}
199 207
200void __init init_boot_display(void) 208int __init btext_find_display(int allow_nonstdout)
201{ 209{
202 char *name; 210 char *name;
203 struct device_node *np = NULL; 211 struct device_node *np = NULL;
@@ -218,8 +226,8 @@ void __init init_boot_display(void)
218 } 226 }
219 if (np) 227 if (np)
220 rc = btext_initialize(np); 228 rc = btext_initialize(np);
221 if (rc == 0) 229 if (rc == 0 || !allow_nonstdout)
222 return; 230 return rc;
223 231
224 for (np = NULL; (np = of_find_node_by_type(np, "display"));) { 232 for (np = NULL; (np = of_find_node_by_type(np, "display"));) {
225 if (get_property(np, "linux,opened", NULL)) { 233 if (get_property(np, "linux,opened", NULL)) {
@@ -228,8 +236,9 @@ void __init init_boot_display(void)
228 printk("result: %d\n", rc); 236 printk("result: %d\n", rc);
229 } 237 }
230 if (rc == 0) 238 if (rc == 0)
231 return; 239 break;
232 } 240 }
241 return rc;
233} 242}
234 243
235/* Calc the base address of a given point (x,y) */ 244/* Calc the base address of a given point (x,y) */
@@ -277,44 +286,83 @@ EXPORT_SYMBOL(btext_update_display);
277 286
278void btext_clearscreen(void) 287void btext_clearscreen(void)
279{ 288{
280 unsigned long *base = (unsigned long *)calc_base(0, 0); 289 unsigned int *base = (unsigned int *)calc_base(0, 0);
281 unsigned long width = ((dispDeviceRect[2] - dispDeviceRect[0]) * 290 unsigned long width = ((dispDeviceRect[2] - dispDeviceRect[0]) *
282 (dispDeviceDepth >> 3)) >> 3; 291 (dispDeviceDepth >> 3)) >> 2;
283 int i,j; 292 int i,j;
284 293
285 for (i=0; i<(dispDeviceRect[3] - dispDeviceRect[1]); i++) 294 for (i=0; i<(dispDeviceRect[3] - dispDeviceRect[1]); i++)
286 { 295 {
287 unsigned long *ptr = base; 296 unsigned int *ptr = base;
288 for(j=width; j; --j) 297 for(j=width; j; --j)
289 *(ptr++) = 0; 298 *(ptr++) = 0;
290 base += (dispDeviceRowBytes >> 3); 299 base += (dispDeviceRowBytes >> 2);
300 }
301}
302
303void btext_flushscreen(void)
304{
305 unsigned int *base = (unsigned int *)calc_base(0, 0);
306 unsigned long width = ((dispDeviceRect[2] - dispDeviceRect[0]) *
307 (dispDeviceDepth >> 3)) >> 2;
308 int i,j;
309
310 for (i=0; i < (dispDeviceRect[3] - dispDeviceRect[1]); i++)
311 {
312 unsigned int *ptr = base;
313 for(j = width; j > 0; j -= 8) {
314 __asm__ __volatile__ ("dcbst 0,%0" :: "r" (ptr));
315 ptr += 8;
316 }
317 base += (dispDeviceRowBytes >> 2);
291 } 318 }
319 __asm__ __volatile__ ("sync" ::: "memory");
292} 320}
293 321
322void btext_flushline(void)
323{
324 unsigned int *base = (unsigned int *)calc_base(0, g_loc_Y << 4);
325 unsigned long width = ((dispDeviceRect[2] - dispDeviceRect[0]) *
326 (dispDeviceDepth >> 3)) >> 2;
327 int i,j;
328
329 for (i=0; i < 16; i++)
330 {
331 unsigned int *ptr = base;
332 for(j = width; j > 0; j -= 8) {
333 __asm__ __volatile__ ("dcbst 0,%0" :: "r" (ptr));
334 ptr += 8;
335 }
336 base += (dispDeviceRowBytes >> 2);
337 }
338 __asm__ __volatile__ ("sync" ::: "memory");
339}
340
341
294#ifndef NO_SCROLL 342#ifndef NO_SCROLL
295static void scrollscreen(void) 343static void scrollscreen(void)
296{ 344{
297 unsigned long *src = (unsigned long *)calc_base(0,16); 345 unsigned int *src = (unsigned int *)calc_base(0,16);
298 unsigned long *dst = (unsigned long *)calc_base(0,0); 346 unsigned int *dst = (unsigned int *)calc_base(0,0);
299 unsigned long width = ((dispDeviceRect[2] - dispDeviceRect[0]) * 347 unsigned long width = ((dispDeviceRect[2] - dispDeviceRect[0]) *
300 (dispDeviceDepth >> 3)) >> 3; 348 (dispDeviceDepth >> 3)) >> 2;
301 int i,j; 349 int i,j;
302 350
303 for (i=0; i<(dispDeviceRect[3] - dispDeviceRect[1] - 16); i++) 351 for (i=0; i<(dispDeviceRect[3] - dispDeviceRect[1] - 16); i++)
304 { 352 {
305 unsigned long *src_ptr = src; 353 unsigned int *src_ptr = src;
306 unsigned long *dst_ptr = dst; 354 unsigned int *dst_ptr = dst;
307 for(j=width; j; --j) 355 for(j=width; j; --j)
308 *(dst_ptr++) = *(src_ptr++); 356 *(dst_ptr++) = *(src_ptr++);
309 src += (dispDeviceRowBytes >> 3); 357 src += (dispDeviceRowBytes >> 2);
310 dst += (dispDeviceRowBytes >> 3); 358 dst += (dispDeviceRowBytes >> 2);
311 } 359 }
312 for (i=0; i<16; i++) 360 for (i=0; i<16; i++)
313 { 361 {
314 unsigned long *dst_ptr = dst; 362 unsigned int *dst_ptr = dst;
315 for(j=width; j; --j) 363 for(j=width; j; --j)
316 *(dst_ptr++) = 0; 364 *(dst_ptr++) = 0;
317 dst += (dispDeviceRowBytes >> 3); 365 dst += (dispDeviceRowBytes >> 2);
318 } 366 }
319} 367}
320#endif /* ndef NO_SCROLL */ 368#endif /* ndef NO_SCROLL */
@@ -377,6 +425,14 @@ void btext_drawstring(const char *c)
377 btext_drawchar(*c++); 425 btext_drawchar(*c++);
378} 426}
379 427
428void btext_drawtext(const char *c, unsigned int len)
429{
430 if (!boot_text_mapped)
431 return;
432 while (len--)
433 btext_drawchar(*c++);
434}
435
380void btext_drawhex(unsigned long v) 436void btext_drawhex(unsigned long v)
381{ 437{
382 char *hex_table = "0123456789abcdef"; 438 char *hex_table = "0123456789abcdef";
diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index ccdf94731e30..fdd34dbd8797 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -153,6 +153,9 @@ __after_mmu_off:
153 bl flush_tlbs 153 bl flush_tlbs
154 154
155 bl initial_bats 155 bl initial_bats
156#if !defined(CONFIG_APUS) && defined(CONFIG_BOOTX_TEXT)
157 bl setup_disp_bat
158#endif
156 159
157/* 160/*
158 * Call setup_cpu for CPU 0 and initialize 6xx Idle 161 * Call setup_cpu for CPU 0 and initialize 6xx Idle
@@ -1306,6 +1309,32 @@ initial_bats:
1306 blr 1309 blr
1307 1310
1308 1311
1312#if !defined(CONFIG_APUS) && defined(CONFIG_BOOTX_TEXT)
1313setup_disp_bat:
1314 /*
1315 * setup the display bat prepared for us in prom.c
1316 */
1317 mflr r8
1318 bl reloc_offset
1319 mtlr r8
1320 addis r8,r3,disp_BAT@ha
1321 addi r8,r8,disp_BAT@l
1322 cmpwi cr0,r8,0
1323 beqlr
1324 lwz r11,0(r8)
1325 lwz r8,4(r8)
1326 mfspr r9,SPRN_PVR
1327 rlwinm r9,r9,16,16,31 /* r9 = 1 for 601, 4 for 604 */
1328 cmpwi 0,r9,1
1329 beq 1f
1330 mtspr SPRN_DBAT3L,r8
1331 mtspr SPRN_DBAT3U,r11
1332 blr
13331: mtspr SPRN_IBAT3L,r8
1334 mtspr SPRN_IBAT3U,r11
1335 blr
1336#endif /* !defined(CONFIG_APUS) && defined(CONFIG_BOOTX_TEXT) */
1337
1309#ifdef CONFIG_8260 1338#ifdef CONFIG_8260
1310/* Jump into the system reset for the rom. 1339/* Jump into the system reset for the rom.
1311 * We first disable the MMU, and then jump to the ROM reset address. 1340 * We first disable the MMU, and then jump to the ROM reset address.
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 02baacf04366..79d434fc14d2 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -40,6 +40,7 @@
40#include <asm/xmon.h> 40#include <asm/xmon.h>
41#include <asm/time.h> 41#include <asm/time.h>
42#include <asm/serial.h> 42#include <asm/serial.h>
43#include <asm/udbg.h>
43 44
44#include "setup.h" 45#include "setup.h"
45 46
@@ -173,12 +174,23 @@ void __init platform_init(void)
173 */ 174 */
174void __init machine_init(unsigned long dt_ptr, unsigned long phys) 175void __init machine_init(unsigned long dt_ptr, unsigned long phys)
175{ 176{
177 /* If btext is enabled, we might have a BAT setup for early display,
178 * thus we do enable some very basic udbg output
179 */
180#ifdef CONFIG_BOOTX_TEXT
181 udbg_putc = btext_drawchar;
182#endif
183
184 /* Do some early initialization based on the flat device tree */
176 early_init_devtree(__va(dt_ptr)); 185 early_init_devtree(__va(dt_ptr));
177 186
187 /* Check default command line */
178#ifdef CONFIG_CMDLINE 188#ifdef CONFIG_CMDLINE
179 strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line)); 189 if (cmd_line[0] == 0)
190 strlcpy(cmd_line, CONFIG_CMDLINE, sizeof(cmd_line));
180#endif /* CONFIG_CMDLINE */ 191#endif /* CONFIG_CMDLINE */
181 192
193 /* Base init based on machine type */
182 platform_init(); 194 platform_init();
183 195
184#ifdef CONFIG_6xx 196#ifdef CONFIG_6xx
@@ -294,21 +306,11 @@ void __init setup_arch(char **cmdline_p)
294 306
295 smp_setup_cpu_maps(); 307 smp_setup_cpu_maps();
296 308
297#ifdef CONFIG_BOOTX_TEXT
298 init_boot_display();
299#endif
300
301#ifdef CONFIG_PPC_PMAC
302 /* This could be called "early setup arch", it must be done
303 * now because xmon need it
304 */
305 if (_machine == _MACH_Pmac)
306 pmac_feature_init(); /* New cool way */
307#endif
308
309#ifdef CONFIG_XMON_DEFAULT 309#ifdef CONFIG_XMON_DEFAULT
310 xmon_init(1); 310 xmon_init(1);
311#endif 311#endif
312 /* Register early console */
313 register_early_udbg_console();
312 314
313#if defined(CONFIG_KGDB) 315#if defined(CONFIG_KGDB)
314 if (ppc_md.kgdb_map_scc) 316 if (ppc_md.kgdb_map_scc)
diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c
index 0fc442ad1d26..65603e9af984 100644
--- a/arch/powerpc/kernel/setup_64.c
+++ b/arch/powerpc/kernel/setup_64.c
@@ -474,10 +474,6 @@ void __init setup_system(void)
474 */ 474 */
475 finish_device_tree(); 475 finish_device_tree();
476 476
477#ifdef CONFIG_BOOTX_TEXT
478 init_boot_display();
479#endif
480
481 /* 477 /*
482 * Initialize xmon 478 * Initialize xmon
483 */ 479 */
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c
index 2e372477d22a..cc2df5e61bb0 100644
--- a/arch/powerpc/kernel/udbg.c
+++ b/arch/powerpc/kernel/udbg.c
@@ -16,8 +16,8 @@
16#include <linux/console.h> 16#include <linux/console.h>
17#include <asm/processor.h> 17#include <asm/processor.h>
18 18
19void (*udbg_putc)(unsigned char c); 19void (*udbg_putc)(char c);
20unsigned char (*udbg_getc)(void); 20char (*udbg_getc)(void);
21int (*udbg_getc_poll)(void); 21int (*udbg_getc_poll)(void);
22 22
23/* udbg library, used by xmon et al */ 23/* udbg library, used by xmon et al */
@@ -78,7 +78,7 @@ int udbg_read(char *buf, int buflen)
78#define UDBG_BUFSIZE 256 78#define UDBG_BUFSIZE 256
79void udbg_printf(const char *fmt, ...) 79void udbg_printf(const char *fmt, ...)
80{ 80{
81 unsigned char buf[UDBG_BUFSIZE]; 81 char buf[UDBG_BUFSIZE];
82 va_list args; 82 va_list args;
83 83
84 va_start(args, fmt); 84 va_start(args, fmt);
@@ -116,6 +116,8 @@ void __init disable_early_printk(void)
116/* called by setup_system */ 116/* called by setup_system */
117void register_early_udbg_console(void) 117void register_early_udbg_console(void)
118{ 118{
119 if (early_console_initialized)
120 return;
119 early_console_initialized = 1; 121 early_console_initialized = 1;
120 register_console(&udbg_console); 122 register_console(&udbg_console);
121} 123}
diff --git a/arch/powerpc/kernel/udbg_16550.c b/arch/powerpc/kernel/udbg_16550.c
index 50fd376446c9..28a58da5592c 100644
--- a/arch/powerpc/kernel/udbg_16550.c
+++ b/arch/powerpc/kernel/udbg_16550.c
@@ -47,7 +47,7 @@ struct NS16550 {
47 47
48static volatile struct NS16550 __iomem *udbg_comport; 48static volatile struct NS16550 __iomem *udbg_comport;
49 49
50static void udbg_550_putc(unsigned char c) 50static void udbg_550_putc(char c)
51{ 51{
52 if (udbg_comport) { 52 if (udbg_comport) {
53 while ((in_8(&udbg_comport->lsr) & LSR_THRE) == 0) 53 while ((in_8(&udbg_comport->lsr) & LSR_THRE) == 0)
@@ -69,7 +69,7 @@ static int udbg_550_getc_poll(void)
69 return -1; 69 return -1;
70} 70}
71 71
72static unsigned char udbg_550_getc(void) 72static char udbg_550_getc(void)
73{ 73{
74 if (udbg_comport) { 74 if (udbg_comport) {
75 while ((in_8(&udbg_comport->lsr) & LSR_DR) == 0) 75 while ((in_8(&udbg_comport->lsr) & LSR_DR) == 0)
diff --git a/arch/powerpc/kernel/udbg_scc.c b/arch/powerpc/kernel/udbg_scc.c
deleted file mode 100644
index 820c53551507..000000000000
--- a/arch/powerpc/kernel/udbg_scc.c
+++ /dev/null
@@ -1,135 +0,0 @@
1/*
2 * udbg for for zilog scc ports as found on Apple PowerMacs
3 *
4 * Copyright (C) 2001-2005 PPC 64 Team, IBM Corp
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version
9 * 2 of the License, or (at your option) any later version.
10 */
11#include <linux/config.h>
12#include <linux/types.h>
13#include <asm/udbg.h>
14#include <asm/processor.h>
15#include <asm/io.h>
16#include <asm/prom.h>
17#include <asm/pmac_feature.h>
18
19extern u8 real_readb(volatile u8 __iomem *addr);
20extern void real_writeb(u8 data, volatile u8 __iomem *addr);
21
22#define SCC_TXRDY 4
23#define SCC_RXRDY 1
24
25static volatile u8 __iomem *sccc;
26static volatile u8 __iomem *sccd;
27
28static void udbg_scc_putc(unsigned char c)
29{
30 if (sccc) {
31 while ((in_8(sccc) & SCC_TXRDY) == 0)
32 ;
33 out_8(sccd, c);
34 if (c == '\n')
35 udbg_scc_putc('\r');
36 }
37}
38
39static int udbg_scc_getc_poll(void)
40{
41 if (sccc) {
42 if ((in_8(sccc) & SCC_RXRDY) != 0)
43 return in_8(sccd);
44 else
45 return -1;
46 }
47 return -1;
48}
49
50static unsigned char udbg_scc_getc(void)
51{
52 if (sccc) {
53 while ((in_8(sccc) & SCC_RXRDY) == 0)
54 ;
55 return in_8(sccd);
56 }
57 return 0;
58}
59
60static unsigned char scc_inittab[] = {
61 13, 0, /* set baud rate divisor */
62 12, 0,
63 14, 1, /* baud rate gen enable, src=rtxc */
64 11, 0x50, /* clocks = br gen */
65 5, 0xea, /* tx 8 bits, assert DTR & RTS */
66 4, 0x46, /* x16 clock, 1 stop */
67 3, 0xc1, /* rx enable, 8 bits */
68};
69
70void udbg_init_scc(struct device_node *np)
71{
72 u32 *reg;
73 unsigned long addr;
74 int i, x;
75
76 if (np == NULL)
77 np = of_find_node_by_name(NULL, "escc");
78 if (np == NULL || np->parent == NULL)
79 return;
80
81 udbg_printf("found SCC...\n");
82 /* Get address within mac-io ASIC */
83 reg = (u32 *)get_property(np, "reg", NULL);
84 if (reg == NULL)
85 return;
86 addr = reg[0];
87 udbg_printf("local addr: %lx\n", addr);
88 /* Get address of mac-io PCI itself */
89 reg = (u32 *)get_property(np->parent, "assigned-addresses", NULL);
90 if (reg == NULL)
91 return;
92 addr += reg[2];
93 udbg_printf("final addr: %lx\n", addr);
94
95 /* Setup for 57600 8N1 */
96 addr += 0x20;
97 sccc = (volatile u8 * __iomem) ioremap(addr & PAGE_MASK, PAGE_SIZE) ;
98 sccc += addr & ~PAGE_MASK;
99 sccd = sccc + 0x10;
100
101 udbg_printf("ioremap result sccc: %p\n", sccc);
102 mb();
103
104 for (i = 20000; i != 0; --i)
105 x = in_8(sccc);
106 out_8(sccc, 0x09); /* reset A or B side */
107 out_8(sccc, 0xc0);
108 for (i = 0; i < sizeof(scc_inittab); ++i)
109 out_8(sccc, scc_inittab[i]);
110
111 udbg_putc = udbg_scc_putc;
112 udbg_getc = udbg_scc_getc;
113 udbg_getc_poll = udbg_scc_getc_poll;
114
115 udbg_puts("Hello World !\n");
116}
117
118static void udbg_real_scc_putc(unsigned char c)
119{
120 while ((real_readb(sccc) & SCC_TXRDY) == 0)
121 ;
122 real_writeb(c, sccd);
123 if (c == '\n')
124 udbg_real_scc_putc('\r');
125}
126
127void udbg_init_pmac_realmode(void)
128{
129 sccc = (volatile u8 __iomem *)0x80013020ul;
130 sccd = (volatile u8 __iomem *)0x80013030ul;
131
132 udbg_putc = udbg_real_scc_putc;
133 udbg_getc = NULL;
134 udbg_getc_poll = NULL;
135}