1 #include <linux/types.h>
2 #include <linux/kernel.h>
5 #include <linux/console.h>
7 #include <linux/vt_kern.h>
8 #include <linux/interrupt.h>
10 #include <asm/setup.h>
11 #include <asm/bootinfo.h>
12 #include <asm/pgtable.h>
13 #include <asm/apollohw.h>
16 #include <asm/machdep.h>
18 u_long sio01_physaddr
;
19 u_long sio23_physaddr
;
23 u_long cpuctrl_physaddr
;
24 u_long timer_physaddr
;
27 extern void dn_sched_init(irq_handler_t handler
);
28 extern void dn_init_IRQ(void);
29 extern unsigned long dn_gettimeoffset(void);
30 extern int dn_dummy_hwclk(int, struct rtc_time
*);
31 extern int dn_dummy_set_clock_mmss(unsigned long);
32 extern void dn_dummy_reset(void);
33 #ifdef CONFIG_HEARTBEAT
34 static void dn_heartbeat(int on
);
36 static irqreturn_t
dn_timer_int(int irq
,void *);
37 static void dn_get_model(char *model
);
38 static const char *apollo_models
[] = {
39 [APOLLO_DN3000
-APOLLO_DN3000
] = "DN3000 (Otter)",
40 [APOLLO_DN3010
-APOLLO_DN3000
] = "DN3010 (Otter)",
41 [APOLLO_DN3500
-APOLLO_DN3000
] = "DN3500 (Cougar II)",
42 [APOLLO_DN4000
-APOLLO_DN3000
] = "DN4000 (Mink)",
43 [APOLLO_DN4500
-APOLLO_DN3000
] = "DN4500 (Roadrunner)"
46 int apollo_parse_bootinfo(const struct bi_record
*record
) {
49 const unsigned long *data
= record
->data
;
63 void dn_setup_model(void) {
66 printk("Apollo hardware found: ");
67 printk("[%s]\n", apollo_models
[apollo_model
- APOLLO_DN3000
]);
69 switch(apollo_model
) {
71 panic("Unknown apollo model");
75 sio01_physaddr
=SAU8_SIO01_PHYSADDR
;
76 rtc_physaddr
=SAU8_RTC_PHYSADDR
;
77 pica_physaddr
=SAU8_PICA
;
78 picb_physaddr
=SAU8_PICB
;
79 cpuctrl_physaddr
=SAU8_CPUCTRL
;
80 timer_physaddr
=SAU8_TIMER
;
83 sio01_physaddr
=SAU7_SIO01_PHYSADDR
;
84 sio23_physaddr
=SAU7_SIO23_PHYSADDR
;
85 rtc_physaddr
=SAU7_RTC_PHYSADDR
;
86 pica_physaddr
=SAU7_PICA
;
87 picb_physaddr
=SAU7_PICB
;
88 cpuctrl_physaddr
=SAU7_CPUCTRL
;
89 timer_physaddr
=SAU7_TIMER
;
92 panic("Apollo model not yet supported");
95 sio01_physaddr
=SAU7_SIO01_PHYSADDR
;
96 sio23_physaddr
=SAU7_SIO23_PHYSADDR
;
97 rtc_physaddr
=SAU7_RTC_PHYSADDR
;
98 pica_physaddr
=SAU7_PICA
;
99 picb_physaddr
=SAU7_PICB
;
100 cpuctrl_physaddr
=SAU7_CPUCTRL
;
101 timer_physaddr
=SAU7_TIMER
;
104 panic("Undefined apollo model");
111 int dn_serial_console_wait_key(struct console
*co
) {
113 while(!(sio01
.srb_csrb
& 1))
115 return sio01
.rhrb_thrb
;
118 void dn_serial_console_write (struct console
*co
, const char *str
,unsigned int count
)
122 sio01
.rhrb_thrb
= (unsigned char)'\r';
123 while (!(sio01
.srb_csrb
& 0x4))
126 sio01
.rhrb_thrb
= (unsigned char)*str
++;
127 while (!(sio01
.srb_csrb
& 0x4))
132 void dn_serial_print (const char *str
)
136 sio01
.rhrb_thrb
= (unsigned char)'\r';
137 while (!(sio01
.srb_csrb
& 0x4))
140 sio01
.rhrb_thrb
= (unsigned char)*str
++;
141 while (!(sio01
.srb_csrb
& 0x4))
146 void __init
config_apollo(void)
152 mach_sched_init
=dn_sched_init
; /* */
153 mach_init_IRQ
=dn_init_IRQ
;
154 mach_gettimeoffset
= dn_gettimeoffset
;
155 mach_max_dma_address
= 0xffffffff;
156 mach_hwclk
= dn_dummy_hwclk
; /* */
157 mach_set_clock_mmss
= dn_dummy_set_clock_mmss
; /* */
158 mach_reset
= dn_dummy_reset
; /* */
159 #ifdef CONFIG_HEARTBEAT
160 mach_heartbeat
= dn_heartbeat
;
162 mach_get_model
= dn_get_model
;
166 /* clear DMA translation table */
172 irqreturn_t
dn_timer_int(int irq
, void *dev_id
)
174 irq_handler_t timer_handler
= dev_id
;
176 volatile unsigned char x
;
178 timer_handler(irq
, dev_id
);
180 x
= *(volatile unsigned char *)(apollo_timer
+ 3);
181 x
= *(volatile unsigned char *)(apollo_timer
+ 5);
186 void dn_sched_init(irq_handler_t timer_routine
)
188 /* program timer 1 */
189 *(volatile unsigned char *)(apollo_timer
+ 3) = 0x01;
190 *(volatile unsigned char *)(apollo_timer
+ 1) = 0x40;
191 *(volatile unsigned char *)(apollo_timer
+ 5) = 0x09;
192 *(volatile unsigned char *)(apollo_timer
+ 7) = 0xc4;
194 /* enable IRQ of PIC B */
195 *(volatile unsigned char *)(pica
+1)&=(~8);
198 printk("*(0x10803) %02x\n",*(volatile unsigned char *)(apollo_timer
+ 0x3));
199 printk("*(0x10803) %02x\n",*(volatile unsigned char *)(apollo_timer
+ 0x3));
202 if (request_irq(IRQ_APOLLO
, dn_timer_int
, 0, "time", timer_routine
))
203 pr_err("Couldn't register timer interrupt\n");
206 unsigned long dn_gettimeoffset(void) {
212 int dn_dummy_hwclk(int op
, struct rtc_time
*t
) {
216 t
->tm_sec
=rtc
->second
;
217 t
->tm_min
=rtc
->minute
;
218 t
->tm_hour
=rtc
->hours
;
219 t
->tm_mday
=rtc
->day_of_month
;
220 t
->tm_wday
=rtc
->day_of_week
;
221 t
->tm_mon
=rtc
->month
;
222 t
->tm_year
=rtc
->year
;
224 rtc
->second
=t
->tm_sec
;
225 rtc
->minute
=t
->tm_min
;
226 rtc
->hours
=t
->tm_hour
;
227 rtc
->day_of_month
=t
->tm_mday
;
229 rtc
->day_of_week
=t
->tm_wday
;
230 rtc
->month
=t
->tm_mon
;
231 rtc
->year
=t
->tm_year
;
238 int dn_dummy_set_clock_mmss(unsigned long nowtime
) {
240 printk("set_clock_mmss\n");
246 void dn_dummy_reset(void) {
248 dn_serial_print("The end !\n");
254 void dn_dummy_waitbut(void) {
256 dn_serial_print("waitbut\n");
260 static void dn_get_model(char *model
)
262 strcpy(model
, "Apollo ");
263 if (apollo_model
>= APOLLO_DN3000
&& apollo_model
<= APOLLO_DN4500
)
264 strcat(model
, apollo_models
[apollo_model
- APOLLO_DN3000
]);
267 #ifdef CONFIG_HEARTBEAT
268 static int dn_cpuctrl
=0xff00;
270 static void dn_heartbeat(int on
) {