1 #include <linux/config.h>
2 #include <linux/types.h>
3 #include <linux/kernel.h>
6 #include <linux/console.h>
8 #include <linux/vt_kern.h>
9 #include <linux/interrupt.h>
11 #include <asm/setup.h>
12 #include <asm/bootinfo.h>
13 #include <asm/system.h>
14 #include <asm/pgtable.h>
15 #include <asm/apollohw.h>
18 #include <asm/machdep.h>
20 u_long sio01_physaddr;
21 u_long sio23_physaddr;
25 u_long cpuctrl_physaddr;
26 u_long timer_physaddr;
29 extern void dn_sched_init(irqreturn_t (*handler)(int,void *,struct pt_regs *));
30 extern void dn_init_IRQ(void);
31 extern unsigned long dn_gettimeoffset(void);
32 extern int dn_dummy_hwclk(int, struct rtc_time *);
33 extern int dn_dummy_set_clock_mmss(unsigned long);
34 extern void dn_dummy_reset(void);
35 extern void dn_dummy_waitbut(void);
36 extern struct fb_info *dn_fb_init(long *);
37 extern void dn_dummy_debug_init(void);
38 extern irqreturn_t dn_process_int(int irq, struct pt_regs *fp);
39 #ifdef CONFIG_HEARTBEAT
40 static void dn_heartbeat(int on);
42 static irqreturn_t dn_timer_int(int irq,void *, struct pt_regs *);
43 static void dn_get_model(char *model);
44 static const char *apollo_models[] = {
45 [APOLLO_DN3000-APOLLO_DN3000] = "DN3000 (Otter)",
46 [APOLLO_DN3010-APOLLO_DN3000] = "DN3010 (Otter)",
47 [APOLLO_DN3500-APOLLO_DN3000] = "DN3500 (Cougar II)",
48 [APOLLO_DN4000-APOLLO_DN3000] = "DN4000 (Mink)",
49 [APOLLO_DN4500-APOLLO_DN3000] = "DN4500 (Roadrunner)"
52 int apollo_parse_bootinfo(const struct bi_record *record) {
55 const unsigned long *data = record->data;
69 void dn_setup_model(void) {
72 printk("Apollo hardware found: ");
73 printk("[%s]\n", apollo_models[apollo_model - APOLLO_DN3000]);
75 switch(apollo_model) {
77 panic("Unknown apollo model");
81 sio01_physaddr=SAU8_SIO01_PHYSADDR;
82 rtc_physaddr=SAU8_RTC_PHYSADDR;
83 pica_physaddr=SAU8_PICA;
84 picb_physaddr=SAU8_PICB;
85 cpuctrl_physaddr=SAU8_CPUCTRL;
86 timer_physaddr=SAU8_TIMER;
89 sio01_physaddr=SAU7_SIO01_PHYSADDR;
90 sio23_physaddr=SAU7_SIO23_PHYSADDR;
91 rtc_physaddr=SAU7_RTC_PHYSADDR;
92 pica_physaddr=SAU7_PICA;
93 picb_physaddr=SAU7_PICB;
94 cpuctrl_physaddr=SAU7_CPUCTRL;
95 timer_physaddr=SAU7_TIMER;
98 panic("Apollo model not yet supported");
101 sio01_physaddr=SAU7_SIO01_PHYSADDR;
102 sio23_physaddr=SAU7_SIO23_PHYSADDR;
103 rtc_physaddr=SAU7_RTC_PHYSADDR;
104 pica_physaddr=SAU7_PICA;
105 picb_physaddr=SAU7_PICB;
106 cpuctrl_physaddr=SAU7_CPUCTRL;
107 timer_physaddr=SAU7_TIMER;
110 panic("Undefined apollo model");
117 int dn_serial_console_wait_key(struct console *co) {
119 while(!(sio01.srb_csrb & 1))
121 return sio01.rhrb_thrb;
124 void dn_serial_console_write (struct console *co, const char *str,unsigned int count)
128 sio01.rhrb_thrb = (unsigned char)'\r';
129 while (!(sio01.srb_csrb & 0x4))
132 sio01.rhrb_thrb = (unsigned char)*str++;
133 while (!(sio01.srb_csrb & 0x4))
138 void dn_serial_print (const char *str)
142 sio01.rhrb_thrb = (unsigned char)'\r';
143 while (!(sio01.srb_csrb & 0x4))
146 sio01.rhrb_thrb = (unsigned char)*str++;
147 while (!(sio01.srb_csrb & 0x4))
152 void config_apollo(void) {
158 mach_sched_init=dn_sched_init; /* */
159 mach_init_IRQ=dn_init_IRQ;
160 mach_gettimeoffset = dn_gettimeoffset;
161 mach_max_dma_address = 0xffffffff;
162 mach_hwclk = dn_dummy_hwclk; /* */
163 mach_set_clock_mmss = dn_dummy_set_clock_mmss; /* */
164 mach_reset = dn_dummy_reset; /* */
165 #ifdef CONFIG_HEARTBEAT
166 mach_heartbeat = dn_heartbeat;
168 mach_get_model = dn_get_model;
172 /* clear DMA translation table */
178 irqreturn_t dn_timer_int(int irq, void *dev_id, struct pt_regs *fp)
180 irqreturn_t (*timer_handler)(int, void *, struct pt_regs *) = dev_id;
182 volatile unsigned char x;
184 timer_handler(irq, dev_id, fp);
186 x=*(volatile unsigned char *)(timer+3);
187 x=*(volatile unsigned char *)(timer+5);
192 void dn_sched_init(irqreturn_t (*timer_routine)(int, void *, struct pt_regs *)) {
194 /* program timer 1 */
195 *(volatile unsigned char *)(timer+3)=0x01;
196 *(volatile unsigned char *)(timer+1)=0x40;
197 *(volatile unsigned char *)(timer+5)=0x09;
198 *(volatile unsigned char *)(timer+7)=0xc4;
200 /* enable IRQ of PIC B */
201 *(volatile unsigned char *)(pica+1)&=(~8);
204 printk("*(0x10803) %02x\n",*(volatile unsigned char *)(timer+0x3));
205 printk("*(0x10803) %02x\n",*(volatile unsigned char *)(timer+0x3));
208 request_irq(IRQ_APOLLO, dn_timer_int, 0, "time", timer_routine);
211 unsigned long dn_gettimeoffset(void) {
217 int dn_dummy_hwclk(int op, struct rtc_time *t) {
221 t->tm_sec=rtc->second;
222 t->tm_min=rtc->minute;
223 t->tm_hour=rtc->hours;
224 t->tm_mday=rtc->day_of_month;
225 t->tm_wday=rtc->day_of_week;
226 t->tm_mon=rtc->month;
227 t->tm_year=rtc->year;
229 rtc->second=t->tm_sec;
230 rtc->minute=t->tm_min;
231 rtc->hours=t->tm_hour;
232 rtc->day_of_month=t->tm_mday;
234 rtc->day_of_week=t->tm_wday;
235 rtc->month=t->tm_mon;
236 rtc->year=t->tm_year;
243 int dn_dummy_set_clock_mmss(unsigned long nowtime) {
245 printk("set_clock_mmss\n");
251 void dn_dummy_reset(void) {
253 dn_serial_print("The end !\n");
259 void dn_dummy_waitbut(void) {
261 dn_serial_print("waitbut\n");
265 static void dn_get_model(char *model)
267 strcpy(model, "Apollo ");
268 if (apollo_model >= APOLLO_DN3000 && apollo_model <= APOLLO_DN4500)
269 strcat(model, apollo_models[apollo_model - APOLLO_DN3000]);
272 #ifdef CONFIG_HEARTBEAT
273 static int dn_cpuctrl=0xff00;
275 static void dn_heartbeat(int on) {