diff options
author | Milton Miller <miltonm@bga.com> | 2005-09-05 21:56:02 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2005-09-06 02:07:36 -0400 |
commit | 7f853352e79bf57c4ee279b7458ed0c072e2be76 (patch) | |
tree | 516f26c2b0e5de059c0fda3c1266285f8084de03 /arch/ppc64 | |
parent | 37548d58e5ce53dda609c5b35c0eb62d50d59675 (diff) |
[PATCH] ppc64: Split SCC and 15550 udbg code
Split scc and 15550 functions from udbg each into their own file.
This makes them more symetric with the lpar and btext code.
Signed-off-by: Milton Miller <miltonm@bga.com>
Signed-off-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/ppc64')
-rw-r--r-- | arch/ppc64/kernel/Makefile | 8 | ||||
-rw-r--r-- | arch/ppc64/kernel/udbg.c | 225 | ||||
-rw-r--r-- | arch/ppc64/kernel/udbg_16550.c | 128 | ||||
-rw-r--r-- | arch/ppc64/kernel/udbg_scc.c | 138 |
4 files changed, 272 insertions, 227 deletions
diff --git a/arch/ppc64/kernel/Makefile b/arch/ppc64/kernel/Makefile index f4b3bfcc109d..ae60eb1193c6 100644 --- a/arch/ppc64/kernel/Makefile +++ b/arch/ppc64/kernel/Makefile | |||
@@ -31,7 +31,7 @@ obj-$(CONFIG_PPC_MULTIPLATFORM) += nvram.o i8259.o prom_init.o prom.o | |||
31 | 31 | ||
32 | obj-$(CONFIG_PPC_PSERIES) += pSeries_pci.o pSeries_lpar.o pSeries_hvCall.o \ | 32 | obj-$(CONFIG_PPC_PSERIES) += pSeries_pci.o pSeries_lpar.o pSeries_hvCall.o \ |
33 | pSeries_nvram.o rtasd.o ras.o pSeries_reconfig.o \ | 33 | pSeries_nvram.o rtasd.o ras.o pSeries_reconfig.o \ |
34 | pSeries_setup.o pSeries_iommu.o | 34 | pSeries_setup.o pSeries_iommu.o udbg_16550.o |
35 | 35 | ||
36 | obj-$(CONFIG_PPC_BPA) += bpa_setup.o bpa_iommu.o bpa_nvram.o \ | 36 | obj-$(CONFIG_PPC_BPA) += bpa_setup.o bpa_iommu.o bpa_nvram.o \ |
37 | bpa_iic.o spider-pic.o | 37 | bpa_iic.o spider-pic.o |
@@ -58,9 +58,11 @@ obj-$(CONFIG_XICS) += xics.o | |||
58 | obj-$(CONFIG_MPIC) += mpic.o | 58 | obj-$(CONFIG_MPIC) += mpic.o |
59 | 59 | ||
60 | obj-$(CONFIG_PPC_PMAC) += pmac_setup.o pmac_feature.o pmac_pci.o \ | 60 | obj-$(CONFIG_PPC_PMAC) += pmac_setup.o pmac_feature.o pmac_pci.o \ |
61 | pmac_time.o pmac_nvram.o pmac_low_i2c.o | 61 | pmac_time.o pmac_nvram.o pmac_low_i2c.o \ |
62 | udbg_scc.o | ||
62 | 63 | ||
63 | obj-$(CONFIG_PPC_MAPLE) += maple_setup.o maple_pci.o maple_time.o | 64 | obj-$(CONFIG_PPC_MAPLE) += maple_setup.o maple_pci.o maple_time.o \ |
65 | udbg_16550.o | ||
64 | 66 | ||
65 | obj-$(CONFIG_U3_DART) += u3_iommu.o | 67 | obj-$(CONFIG_U3_DART) += u3_iommu.o |
66 | 68 | ||
diff --git a/arch/ppc64/kernel/udbg.c b/arch/ppc64/kernel/udbg.c index b531583b88d7..67e208500aea 100644 --- a/arch/ppc64/kernel/udbg.c +++ b/arch/ppc64/kernel/udbg.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * NS16550 Serial Port (uart) debugging stuff. | 2 | * polling mode stateless debugging stuff, originally for NS16550 Serial Ports |
3 | * | 3 | * |
4 | * c 2001 PPC 64 Team, IBM Corp | 4 | * c 2001 PPC 64 Team, IBM Corp |
5 | * | 5 | * |
@@ -19,229 +19,6 @@ | |||
19 | #include <asm/machdep.h> | 19 | #include <asm/machdep.h> |
20 | #include <asm/io.h> | 20 | #include <asm/io.h> |
21 | #include <asm/prom.h> | 21 | #include <asm/prom.h> |
22 | #include <asm/pmac_feature.h> | ||
23 | |||
24 | extern u8 real_readb(volatile u8 __iomem *addr); | ||
25 | extern void real_writeb(u8 data, volatile u8 __iomem *addr); | ||
26 | |||
27 | struct NS16550 { | ||
28 | /* this struct must be packed */ | ||
29 | unsigned char rbr; /* 0 */ | ||
30 | unsigned char ier; /* 1 */ | ||
31 | unsigned char fcr; /* 2 */ | ||
32 | unsigned char lcr; /* 3 */ | ||
33 | unsigned char mcr; /* 4 */ | ||
34 | unsigned char lsr; /* 5 */ | ||
35 | unsigned char msr; /* 6 */ | ||
36 | unsigned char scr; /* 7 */ | ||
37 | }; | ||
38 | |||
39 | #define thr rbr | ||
40 | #define iir fcr | ||
41 | #define dll rbr | ||
42 | #define dlm ier | ||
43 | #define dlab lcr | ||
44 | |||
45 | #define LSR_DR 0x01 /* Data ready */ | ||
46 | #define LSR_OE 0x02 /* Overrun */ | ||
47 | #define LSR_PE 0x04 /* Parity error */ | ||
48 | #define LSR_FE 0x08 /* Framing error */ | ||
49 | #define LSR_BI 0x10 /* Break */ | ||
50 | #define LSR_THRE 0x20 /* Xmit holding register empty */ | ||
51 | #define LSR_TEMT 0x40 /* Xmitter empty */ | ||
52 | #define LSR_ERR 0x80 /* Error */ | ||
53 | |||
54 | static volatile struct NS16550 __iomem *udbg_comport; | ||
55 | |||
56 | void udbg_init_uart(void __iomem *comport, unsigned int speed) | ||
57 | { | ||
58 | u16 dll = speed ? (115200 / speed) : 12; | ||
59 | |||
60 | if (comport) { | ||
61 | udbg_comport = (struct NS16550 __iomem *)comport; | ||
62 | out_8(&udbg_comport->lcr, 0x00); | ||
63 | out_8(&udbg_comport->ier, 0xff); | ||
64 | out_8(&udbg_comport->ier, 0x00); | ||
65 | out_8(&udbg_comport->lcr, 0x80); /* Access baud rate */ | ||
66 | out_8(&udbg_comport->dll, dll & 0xff); /* 1 = 115200, 2 = 57600, | ||
67 | 3 = 38400, 12 = 9600 baud */ | ||
68 | out_8(&udbg_comport->dlm, dll >> 8); /* dll >> 8 which should be zero | ||
69 | for fast rates; */ | ||
70 | out_8(&udbg_comport->lcr, 0x03); /* 8 data, 1 stop, no parity */ | ||
71 | out_8(&udbg_comport->mcr, 0x03); /* RTS/DTR */ | ||
72 | out_8(&udbg_comport->fcr ,0x07); /* Clear & enable FIFOs */ | ||
73 | ppc_md.udbg_putc = udbg_putc; /* set access methods */ | ||
74 | ppc_md.udbg_getc = udbg_getc; | ||
75 | ppc_md.udbg_getc_poll = udbg_getc_poll; | ||
76 | } | ||
77 | } | ||
78 | |||
79 | #ifdef CONFIG_PPC_PMAC | ||
80 | |||
81 | #define SCC_TXRDY 4 | ||
82 | #define SCC_RXRDY 1 | ||
83 | |||
84 | static volatile u8 __iomem *sccc; | ||
85 | static volatile u8 __iomem *sccd; | ||
86 | |||
87 | static unsigned char scc_inittab[] = { | ||
88 | 13, 0, /* set baud rate divisor */ | ||
89 | 12, 0, | ||
90 | 14, 1, /* baud rate gen enable, src=rtxc */ | ||
91 | 11, 0x50, /* clocks = br gen */ | ||
92 | 5, 0xea, /* tx 8 bits, assert DTR & RTS */ | ||
93 | 4, 0x46, /* x16 clock, 1 stop */ | ||
94 | 3, 0xc1, /* rx enable, 8 bits */ | ||
95 | }; | ||
96 | |||
97 | void udbg_init_scc(struct device_node *np) | ||
98 | { | ||
99 | u32 *reg; | ||
100 | unsigned long addr; | ||
101 | int i, x; | ||
102 | |||
103 | if (np == NULL) | ||
104 | np = of_find_node_by_name(NULL, "escc"); | ||
105 | if (np == NULL || np->parent == NULL) | ||
106 | return; | ||
107 | |||
108 | udbg_printf("found SCC...\n"); | ||
109 | /* Get address within mac-io ASIC */ | ||
110 | reg = (u32 *)get_property(np, "reg", NULL); | ||
111 | if (reg == NULL) | ||
112 | return; | ||
113 | addr = reg[0]; | ||
114 | udbg_printf("local addr: %lx\n", addr); | ||
115 | /* Get address of mac-io PCI itself */ | ||
116 | reg = (u32 *)get_property(np->parent, "assigned-addresses", NULL); | ||
117 | if (reg == NULL) | ||
118 | return; | ||
119 | addr += reg[2]; | ||
120 | udbg_printf("final addr: %lx\n", addr); | ||
121 | |||
122 | /* Setup for 57600 8N1 */ | ||
123 | addr += 0x20; | ||
124 | sccc = (volatile u8 * __iomem) ioremap(addr & PAGE_MASK, PAGE_SIZE) ; | ||
125 | sccc += addr & ~PAGE_MASK; | ||
126 | sccd = sccc + 0x10; | ||
127 | |||
128 | udbg_printf("ioremap result sccc: %p\n", sccc); | ||
129 | mb(); | ||
130 | |||
131 | for (i = 20000; i != 0; --i) | ||
132 | x = in_8(sccc); | ||
133 | out_8(sccc, 0x09); /* reset A or B side */ | ||
134 | out_8(sccc, 0xc0); | ||
135 | for (i = 0; i < sizeof(scc_inittab); ++i) | ||
136 | out_8(sccc, scc_inittab[i]); | ||
137 | |||
138 | ppc_md.udbg_putc = udbg_putc; | ||
139 | ppc_md.udbg_getc = udbg_getc; | ||
140 | ppc_md.udbg_getc_poll = udbg_getc_poll; | ||
141 | |||
142 | udbg_puts("Hello World !\n"); | ||
143 | } | ||
144 | |||
145 | #endif /* CONFIG_PPC_PMAC */ | ||
146 | |||
147 | #ifdef CONFIG_PPC_PMAC | ||
148 | static void udbg_real_putc(unsigned char c) | ||
149 | { | ||
150 | while ((real_readb(sccc) & SCC_TXRDY) == 0) | ||
151 | ; | ||
152 | real_writeb(c, sccd); | ||
153 | if (c == '\n') | ||
154 | udbg_real_putc('\r'); | ||
155 | } | ||
156 | |||
157 | void udbg_init_pmac_realmode(void) | ||
158 | { | ||
159 | sccc = (volatile u8 __iomem *)0x80013020ul; | ||
160 | sccd = (volatile u8 __iomem *)0x80013030ul; | ||
161 | |||
162 | ppc_md.udbg_putc = udbg_real_putc; | ||
163 | ppc_md.udbg_getc = NULL; | ||
164 | ppc_md.udbg_getc_poll = NULL; | ||
165 | } | ||
166 | #endif /* CONFIG_PPC_PMAC */ | ||
167 | |||
168 | #ifdef CONFIG_PPC_MAPLE | ||
169 | void udbg_maple_real_putc(unsigned char c) | ||
170 | { | ||
171 | if (udbg_comport) { | ||
172 | while ((real_readb(&udbg_comport->lsr) & LSR_THRE) == 0) | ||
173 | /* wait for idle */; | ||
174 | real_writeb(c, &udbg_comport->thr); eieio(); | ||
175 | if (c == '\n') | ||
176 | udbg_maple_real_putc('\r'); | ||
177 | } | ||
178 | } | ||
179 | |||
180 | void udbg_init_maple_realmode(void) | ||
181 | { | ||
182 | udbg_comport = (volatile struct NS16550 __iomem *)0xf40003f8; | ||
183 | |||
184 | ppc_md.udbg_putc = udbg_maple_real_putc; | ||
185 | ppc_md.udbg_getc = NULL; | ||
186 | ppc_md.udbg_getc_poll = NULL; | ||
187 | } | ||
188 | #endif /* CONFIG_PPC_MAPLE */ | ||
189 | |||
190 | void udbg_putc(unsigned char c) | ||
191 | { | ||
192 | if (udbg_comport) { | ||
193 | while ((in_8(&udbg_comport->lsr) & LSR_THRE) == 0) | ||
194 | /* wait for idle */; | ||
195 | out_8(&udbg_comport->thr, c); | ||
196 | if (c == '\n') | ||
197 | udbg_putc('\r'); | ||
198 | } | ||
199 | #ifdef CONFIG_PPC_PMAC | ||
200 | else if (sccc) { | ||
201 | while ((in_8(sccc) & SCC_TXRDY) == 0) | ||
202 | ; | ||
203 | out_8(sccd, c); | ||
204 | if (c == '\n') | ||
205 | udbg_putc('\r'); | ||
206 | } | ||
207 | #endif /* CONFIG_PPC_PMAC */ | ||
208 | } | ||
209 | |||
210 | int udbg_getc_poll(void) | ||
211 | { | ||
212 | if (udbg_comport) { | ||
213 | if ((in_8(&udbg_comport->lsr) & LSR_DR) != 0) | ||
214 | return in_8(&udbg_comport->rbr); | ||
215 | else | ||
216 | return -1; | ||
217 | } | ||
218 | #ifdef CONFIG_PPC_PMAC | ||
219 | else if (sccc) { | ||
220 | if ((in_8(sccc) & SCC_RXRDY) != 0) | ||
221 | return in_8(sccd); | ||
222 | else | ||
223 | return -1; | ||
224 | } | ||
225 | #endif /* CONFIG_PPC_PMAC */ | ||
226 | return -1; | ||
227 | } | ||
228 | |||
229 | unsigned char udbg_getc(void) | ||
230 | { | ||
231 | if (udbg_comport) { | ||
232 | while ((in_8(&udbg_comport->lsr) & LSR_DR) == 0) | ||
233 | /* wait for char */; | ||
234 | return in_8(&udbg_comport->rbr); | ||
235 | } | ||
236 | #ifdef CONFIG_PPC_PMAC | ||
237 | else if (sccc) { | ||
238 | while ((in_8(sccc) & SCC_RXRDY) == 0) | ||
239 | ; | ||
240 | return in_8(sccd); | ||
241 | } | ||
242 | #endif /* CONFIG_PPC_PMAC */ | ||
243 | return 0; | ||
244 | } | ||
245 | 22 | ||
246 | void udbg_puts(const char *s) | 23 | void udbg_puts(const char *s) |
247 | { | 24 | { |
diff --git a/arch/ppc64/kernel/udbg_16550.c b/arch/ppc64/kernel/udbg_16550.c new file mode 100644 index 000000000000..46a23e34f7c9 --- /dev/null +++ b/arch/ppc64/kernel/udbg_16550.c | |||
@@ -0,0 +1,128 @@ | |||
1 | /* | ||
2 | * udbg for for NS16550 compatable serial ports | ||
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/ppcdebug.h> | ||
14 | #include <asm/processor.h> | ||
15 | #include <asm/naca.h> | ||
16 | #include <asm/uaccess.h> | ||
17 | #include <asm/machdep.h> | ||
18 | #include <asm/io.h> | ||
19 | #include <asm/prom.h> | ||
20 | |||
21 | extern u8 real_readb(volatile u8 __iomem *addr); | ||
22 | extern void real_writeb(u8 data, volatile u8 __iomem *addr); | ||
23 | |||
24 | struct NS16550 { | ||
25 | /* this struct must be packed */ | ||
26 | unsigned char rbr; /* 0 */ | ||
27 | unsigned char ier; /* 1 */ | ||
28 | unsigned char fcr; /* 2 */ | ||
29 | unsigned char lcr; /* 3 */ | ||
30 | unsigned char mcr; /* 4 */ | ||
31 | unsigned char lsr; /* 5 */ | ||
32 | unsigned char msr; /* 6 */ | ||
33 | unsigned char scr; /* 7 */ | ||
34 | }; | ||
35 | |||
36 | #define thr rbr | ||
37 | #define iir fcr | ||
38 | #define dll rbr | ||
39 | #define dlm ier | ||
40 | #define dlab lcr | ||
41 | |||
42 | #define LSR_DR 0x01 /* Data ready */ | ||
43 | #define LSR_OE 0x02 /* Overrun */ | ||
44 | #define LSR_PE 0x04 /* Parity error */ | ||
45 | #define LSR_FE 0x08 /* Framing error */ | ||
46 | #define LSR_BI 0x10 /* Break */ | ||
47 | #define LSR_THRE 0x20 /* Xmit holding register empty */ | ||
48 | #define LSR_TEMT 0x40 /* Xmitter empty */ | ||
49 | #define LSR_ERR 0x80 /* Error */ | ||
50 | |||
51 | static volatile struct NS16550 __iomem *udbg_comport; | ||
52 | |||
53 | static void udbg_550_putc(unsigned char c) | ||
54 | { | ||
55 | if (udbg_comport) { | ||
56 | while ((in_8(&udbg_comport->lsr) & LSR_THRE) == 0) | ||
57 | /* wait for idle */; | ||
58 | out_8(&udbg_comport->thr, c); | ||
59 | if (c == '\n') | ||
60 | udbg_550_putc('\r'); | ||
61 | } | ||
62 | } | ||
63 | |||
64 | static int udbg_550_getc_poll(void) | ||
65 | { | ||
66 | if (udbg_comport) { | ||
67 | if ((in_8(&udbg_comport->lsr) & LSR_DR) != 0) | ||
68 | return in_8(&udbg_comport->rbr); | ||
69 | else | ||
70 | return -1; | ||
71 | } | ||
72 | return -1; | ||
73 | } | ||
74 | |||
75 | static unsigned char udbg_550_getc(void) | ||
76 | { | ||
77 | if (udbg_comport) { | ||
78 | while ((in_8(&udbg_comport->lsr) & LSR_DR) == 0) | ||
79 | /* wait for char */; | ||
80 | return in_8(&udbg_comport->rbr); | ||
81 | } | ||
82 | return 0; | ||
83 | } | ||
84 | |||
85 | void udbg_init_uart(void __iomem *comport, unsigned int speed) | ||
86 | { | ||
87 | u16 dll = speed ? (115200 / speed) : 12; | ||
88 | |||
89 | if (comport) { | ||
90 | udbg_comport = (struct NS16550 __iomem *)comport; | ||
91 | out_8(&udbg_comport->lcr, 0x00); | ||
92 | out_8(&udbg_comport->ier, 0xff); | ||
93 | out_8(&udbg_comport->ier, 0x00); | ||
94 | out_8(&udbg_comport->lcr, 0x80); /* Access baud rate */ | ||
95 | out_8(&udbg_comport->dll, dll & 0xff); /* 1 = 115200, 2 = 57600, | ||
96 | 3 = 38400, 12 = 9600 baud */ | ||
97 | out_8(&udbg_comport->dlm, dll >> 8); /* dll >> 8 which should be zero | ||
98 | for fast rates; */ | ||
99 | out_8(&udbg_comport->lcr, 0x03); /* 8 data, 1 stop, no parity */ | ||
100 | out_8(&udbg_comport->mcr, 0x03); /* RTS/DTR */ | ||
101 | out_8(&udbg_comport->fcr ,0x07); /* Clear & enable FIFOs */ | ||
102 | ppc_md.udbg_putc = udbg_550_putc; | ||
103 | ppc_md.udbg_getc = udbg_550_getc; | ||
104 | ppc_md.udbg_getc_poll = udbg_550_getc_poll; | ||
105 | } | ||
106 | } | ||
107 | |||
108 | #ifdef CONFIG_PPC_MAPLE | ||
109 | void udbg_maple_real_putc(unsigned char c) | ||
110 | { | ||
111 | if (udbg_comport) { | ||
112 | while ((real_readb(&udbg_comport->lsr) & LSR_THRE) == 0) | ||
113 | /* wait for idle */; | ||
114 | real_writeb(c, &udbg_comport->thr); eieio(); | ||
115 | if (c == '\n') | ||
116 | udbg_maple_real_putc('\r'); | ||
117 | } | ||
118 | } | ||
119 | |||
120 | void udbg_init_maple_realmode(void) | ||
121 | { | ||
122 | udbg_comport = (volatile struct NS16550 __iomem *)0xf40003f8; | ||
123 | |||
124 | ppc_md.udbg_putc = udbg_maple_real_putc; | ||
125 | ppc_md.udbg_getc = NULL; | ||
126 | ppc_md.udbg_getc_poll = NULL; | ||
127 | } | ||
128 | #endif /* CONFIG_PPC_MAPLE */ | ||
diff --git a/arch/ppc64/kernel/udbg_scc.c b/arch/ppc64/kernel/udbg_scc.c new file mode 100644 index 000000000000..74c8ea2675cb --- /dev/null +++ b/arch/ppc64/kernel/udbg_scc.c | |||
@@ -0,0 +1,138 @@ | |||
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/ppcdebug.h> | ||
14 | #include <asm/processor.h> | ||
15 | #include <asm/naca.h> | ||
16 | #include <asm/uaccess.h> | ||
17 | #include <asm/machdep.h> | ||
18 | #include <asm/io.h> | ||
19 | #include <asm/prom.h> | ||
20 | #include <asm/pmac_feature.h> | ||
21 | |||
22 | extern u8 real_readb(volatile u8 __iomem *addr); | ||
23 | extern void real_writeb(u8 data, volatile u8 __iomem *addr); | ||
24 | |||
25 | #define SCC_TXRDY 4 | ||
26 | #define SCC_RXRDY 1 | ||
27 | |||
28 | static volatile u8 __iomem *sccc; | ||
29 | static volatile u8 __iomem *sccd; | ||
30 | |||
31 | static void udbg_scc_putc(unsigned char c) | ||
32 | { | ||
33 | if (sccc) { | ||
34 | while ((in_8(sccc) & SCC_TXRDY) == 0) | ||
35 | ; | ||
36 | out_8(sccd, c); | ||
37 | if (c == '\n') | ||
38 | udbg_scc_putc('\r'); | ||
39 | } | ||
40 | } | ||
41 | |||
42 | static int udbg_scc_getc_poll(void) | ||
43 | { | ||
44 | if (sccc) { | ||
45 | if ((in_8(sccc) & SCC_RXRDY) != 0) | ||
46 | return in_8(sccd); | ||
47 | else | ||
48 | return -1; | ||
49 | } | ||
50 | return -1; | ||
51 | } | ||
52 | |||
53 | static unsigned char udbg_scc_getc(void) | ||
54 | { | ||
55 | if (sccc) { | ||
56 | while ((in_8(sccc) & SCC_RXRDY) == 0) | ||
57 | ; | ||
58 | return in_8(sccd); | ||
59 | } | ||
60 | return 0; | ||
61 | } | ||
62 | |||
63 | static unsigned char scc_inittab[] = { | ||
64 | 13, 0, /* set baud rate divisor */ | ||
65 | 12, 0, | ||
66 | 14, 1, /* baud rate gen enable, src=rtxc */ | ||
67 | 11, 0x50, /* clocks = br gen */ | ||
68 | 5, 0xea, /* tx 8 bits, assert DTR & RTS */ | ||
69 | 4, 0x46, /* x16 clock, 1 stop */ | ||
70 | 3, 0xc1, /* rx enable, 8 bits */ | ||
71 | }; | ||
72 | |||
73 | void udbg_init_scc(struct device_node *np) | ||
74 | { | ||
75 | u32 *reg; | ||
76 | unsigned long addr; | ||
77 | int i, x; | ||
78 | |||
79 | if (np == NULL) | ||
80 | np = of_find_node_by_name(NULL, "escc"); | ||
81 | if (np == NULL || np->parent == NULL) | ||
82 | return; | ||
83 | |||
84 | udbg_printf("found SCC...\n"); | ||
85 | /* Get address within mac-io ASIC */ | ||
86 | reg = (u32 *)get_property(np, "reg", NULL); | ||
87 | if (reg == NULL) | ||
88 | return; | ||
89 | addr = reg[0]; | ||
90 | udbg_printf("local addr: %lx\n", addr); | ||
91 | /* Get address of mac-io PCI itself */ | ||
92 | reg = (u32 *)get_property(np->parent, "assigned-addresses", NULL); | ||
93 | if (reg == NULL) | ||
94 | return; | ||
95 | addr += reg[2]; | ||
96 | udbg_printf("final addr: %lx\n", addr); | ||
97 | |||
98 | /* Setup for 57600 8N1 */ | ||
99 | addr += 0x20; | ||
100 | sccc = (volatile u8 * __iomem) ioremap(addr & PAGE_MASK, PAGE_SIZE) ; | ||
101 | sccc += addr & ~PAGE_MASK; | ||
102 | sccd = sccc + 0x10; | ||
103 | |||
104 | udbg_printf("ioremap result sccc: %p\n", sccc); | ||
105 | mb(); | ||
106 | |||
107 | for (i = 20000; i != 0; --i) | ||
108 | x = in_8(sccc); | ||
109 | out_8(sccc, 0x09); /* reset A or B side */ | ||
110 | out_8(sccc, 0xc0); | ||
111 | for (i = 0; i < sizeof(scc_inittab); ++i) | ||
112 | out_8(sccc, scc_inittab[i]); | ||
113 | |||
114 | ppc_md.udbg_putc = udbg_scc_putc; | ||
115 | ppc_md.udbg_getc = udbg_scc_getc; | ||
116 | ppc_md.udbg_getc_poll = udbg_scc_getc_poll; | ||
117 | |||
118 | udbg_puts("Hello World !\n"); | ||
119 | } | ||
120 | |||
121 | static void udbg_real_scc_putc(unsigned char c) | ||
122 | { | ||
123 | while ((real_readb(sccc) & SCC_TXRDY) == 0) | ||
124 | ; | ||
125 | real_writeb(c, sccd); | ||
126 | if (c == '\n') | ||
127 | udbg_real_scc_putc('\r'); | ||
128 | } | ||
129 | |||
130 | void udbg_init_pmac_realmode(void) | ||
131 | { | ||
132 | sccc = (volatile u8 __iomem *)0x80013020ul; | ||
133 | sccd = (volatile u8 __iomem *)0x80013030ul; | ||
134 | |||
135 | ppc_md.udbg_putc = udbg_real_scc_putc; | ||
136 | ppc_md.udbg_getc = NULL; | ||
137 | ppc_md.udbg_getc_poll = NULL; | ||
138 | } | ||