1 /* $NetBSD: tx39.c,v 1.39 2008/04/28 20:23:21 martin Exp $ */
4 * Copyright (c) 1999, 2000 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
32 #include <sys/cdefs.h>
33 __KERNEL_RCSID(0, "$NetBSD: tx39.c,v 1.39 2008/04/28 20:23:21 martin Exp $");
35 #include "opt_vr41xx.h"
36 #include "opt_tx39xx.h"
38 #include "tc5165buf.h"
40 #include <sys/param.h>
41 #include <sys/systm.h>
43 #include <uvm/uvm_extern.h>
45 #include <mips/cache.h>
47 #include <machine/locore.h> /* cpu_id */
48 #include <machine/bootinfo.h> /* bootinfo */
49 #include <machine/sysconf.h> /* platform */
51 #include <machine/platid.h>
52 #include <machine/platid_mask.h>
54 #include <machine/bus.h>
56 #include <hpcmips/tx/tx39biureg.h>
57 #include <hpcmips/tx/tx39reg.h>
58 #include <hpcmips/tx/tx39var.h>
60 #include <hpcmips/tx/tx3912videovar.h>
63 #include <sys/termios.h>
64 #include <sys/ttydefaults.h>
65 #include <hpcmips/tx/tx39uartvar.h>
67 #define CONSPEED TTYDEF_SPEED
70 /* console keyboard */
72 #include <hpcmips/dev/m38813cvar.h>
75 #include <hpcmips/dev/tc5165bufvar.h>
78 struct tx_chipset_tag tx_chipset
;
81 #if defined(VR41XX) && defined(TX39XX)
82 #define TX_INTR tx_intr
84 #define TX_INTR cpu_intr /* locore_mips3 directly call this */
87 extern void TX_INTR(u_int32_t
, u_int32_t
, u_int32_t
, u_int32_t
);
89 void tx39clock_cpuspeed(int *, int *);
91 /* TX39-specific initialization vector */
92 void tx_cons_init(void);
93 void tx_fb_init(void **);
94 void tx_mem_init(paddr_t
);
95 void tx_find_dram(paddr_t
, paddr_t
);
96 void tx_reboot(int, char *);
105 tc
= tx_conf_get_tag();
107 * Platform Specific Function Hooks
109 platform
.cpu_intr
= TX_INTR
;
110 platform
.cpu_idle
= NULL
; /* not implemented yet */
111 platform
.cons_init
= tx_cons_init
;
112 platform
.fb_init
= tx_fb_init
;
113 platform
.mem_init
= tx_mem_init
;
114 platform
.reboot
= tx_reboot
;
117 model
= MIPS_PRID_REV(cpu_id
);
121 /* Unknown TOSHIBA TX39-series */
122 sprintf(cpu_name
, "Unknown TOSHIBA TX39-series %x", model
);
125 tx39clock_cpuspeed(&cpuclock
, &cpuspeed
);
127 sprintf(cpu_name
, "TOSHIBA TMPR3912 %d.%02d MHz",
128 cpuclock
/ 1000000, (cpuclock
% 1000000) / 10000);
129 tc
->tc_chipset
= __TX391X
;
132 tx39clock_cpuspeed(&cpuclock
, &cpuspeed
);
133 rev
= tx_conf_read(tc
, TX3922_REVISION_REG
);
135 sprintf(cpu_name
, "TOSHIBA TMPR3922 rev. %x.%x "
136 "%d.%02d MHz", (rev
>> 4) & 0xf, rev
& 0xf,
137 cpuclock
/ 1000000, (cpuclock
% 1000000) / 10000);
138 tc
->tc_chipset
= __TX392X
;
144 tx_fb_init(void **kernend
)
149 fb_end
= MIPS_KSEG0_TO_PHYS(mem_clusters
[0].start
+
150 mem_clusters
[0].size
- 1);
151 tx3912video_init(MIPS_KSEG0_TO_PHYS(*kernend
), &fb_end
);
153 /* Skip V-RAM area */
154 *kernend
= (void *)MIPS_PHYS_TO_KSEG0(fb_end
);
158 * Plum V-RAM isn't accessible until pmap_bootstrap,
159 * at this time, frame buffer device is disabled.
161 bootinfo
->fb_addr
= 0;
166 tx_mem_init(paddr_t kernend
)
169 mem_clusters
[0].start
= 0;
170 mem_clusters
[0].size
= kernend
;
172 /* search DRAM bank 0 */
173 tx_find_dram(kernend
, 0x02000000);
175 /* search DRAM bank 1 */
176 tx_find_dram(0x02000000, 0x04000000);
180 tx_find_dram(paddr_t start
, paddr_t end
)
182 char *page
, *startaddr
, *endaddr
;
183 u_int32_t magic0
, magic1
;
184 #define MAGIC0 (*(volatile u_int32_t *)(page + 0))
185 #define MAGIC1 (*(volatile u_int32_t *)(page + 4))
187 startaddr
= (char *)MIPS_PHYS_TO_KSEG1(start
);
188 endaddr
= (char *)MIPS_PHYS_TO_KSEG1(end
);
191 if (badaddr(page
, 4))
197 } while (MAGIC0
== magic0
|| MAGIC0
== magic1
);
203 if (MAGIC0
!= magic0
|| MAGIC1
!= magic1
)
206 for (page
+= PAGE_SIZE
; page
< endaddr
; page
+= PAGE_SIZE
) {
207 if (badaddr(page
, 4))
209 if (MAGIC0
== magic0
&&
215 /* check for 32MByte memory */
220 if (MAGIC0
!= magic0
|| MAGIC1
!= magic1
)
221 return; /* no memory in this bank */
224 mem_clusters
[mem_cluster_cnt
].start
= start
;
225 mem_clusters
[mem_cluster_cnt
].size
= page
- startaddr
;
227 /* skip kernel area */
228 if (mem_cluster_cnt
== 1)
229 mem_clusters
[mem_cluster_cnt
].size
-= start
;
237 tx_reboot(int howto
, char *bootstr
)
240 goto *(u_int32_t
*)MIPS_RESET_EXC_VEC
;
247 #define CONSPLATIDMATCH(p) \
248 platid_match(&platid, &platid_mask_MACH_##p)
250 #ifdef SERIALCONSSLOT
251 slot
= SERIALCONSSLOT
;
255 if (bootinfo
->bi_cnuse
& BI_CNUSE_SERIAL
) {
256 if(txcom_cnattach(slot
, CONSPEED
,
257 (TTYDEF_CFLAG
& ~(CSIZE
| PARENB
)) | CS8
)) {
258 panic("tx_cons_init: can't attach serial console.");
262 if(CONSPLATIDMATCH(VICTOR_INTERLINK
) &&
263 m38813c_cnattach(TX39_SYSADDR_CARD1
)) {
268 if(CONSPLATIDMATCH(COMPAQ_C
) &&
269 tc5165buf_cnattach(TX39_SYSADDR_CS3
)) {
273 if(CONSPLATIDMATCH(SHARP_TELIOS
) &&
274 tc5165buf_cnattach(TX39_SYSADDR_CS1
)) {
278 if(CONSPLATIDMATCH(SHARP_MOBILON
) &&
279 tc5165buf_cnattach(TX39_SYSADDR_MCS0
)) {
287 panic("tx_cons_init: can't init console");
292 tx_conf_register_intr(tx_chipset_tag_t t
, void *intrt
)
295 KASSERT(t
== &tx_chipset
);
296 tx_chipset
.tc_intrt
= intrt
;
300 tx_conf_register_power(tx_chipset_tag_t t
, void *powert
)
303 KASSERT(t
== &tx_chipset
);
304 tx_chipset
.tc_powert
= powert
;
308 tx_conf_register_clock(tx_chipset_tag_t t
, void *clockt
)
311 KASSERT(t
== &tx_chipset
);
312 tx_chipset
.tc_clockt
= clockt
;
316 tx_conf_register_sound(tx_chipset_tag_t t
, void *soundt
)
319 KASSERT(t
== &tx_chipset
);
320 tx_chipset
.tc_soundt
= soundt
;
324 tx_conf_register_video(tx_chipset_tag_t t
, void *videot
)
327 KASSERT(t
== &tx_chipset
);
328 tx_chipset
.tc_videot
= videot
;